feat: 新增验证码接口
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\View;
|
||||
|
||||
class Index
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return '您好!这是一个[admin]示例应用';
|
||||
}
|
||||
}
|
||||
21
app/admin/controller/v1/Captcha.php
Normal file
21
app/admin/controller/v1/Captcha.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
declare (strict_types = 0);
|
||||
|
||||
namespace app\admin\controller\v1;
|
||||
|
||||
use think\facade\Config;
|
||||
|
||||
class Captcha
|
||||
{
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
public function index(\think\Config $config, \think\Session $session)
|
||||
{
|
||||
// 输出验证码
|
||||
$captcha = new \think\captcha\Captcha($config, $session);
|
||||
$data = $captcha->create();
|
||||
|
||||
return success('获取验证码成功!', $data["img"]);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@
|
||||
"topthink/think-filesystem": "^2.0",
|
||||
"topthink/think-multi-app": "^1.1",
|
||||
"topthink/think-migration": "^3.1",
|
||||
"topthink/think-view": "^2.0"
|
||||
"topthink/think-view": "^2.0",
|
||||
"topthink/think-captcha": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": ">=4.2",
|
||||
|
||||
43
config/captcha.php
Normal file
43
config/captcha.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Captcha配置文件
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
//验证码位数
|
||||
'length' => 5,
|
||||
// 验证码字符集合
|
||||
'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
|
||||
// 验证码过期时间
|
||||
'expire' => 1800,
|
||||
// 是否使用中文验证码
|
||||
'useZh' => false,
|
||||
// 是否使用算术验证码
|
||||
'math' => false,
|
||||
// 是否使用背景图
|
||||
'useImgBg' => false,
|
||||
//验证码字符大小
|
||||
'fontSize' => 25,
|
||||
// 是否使用混淆曲线
|
||||
'useCurve' => true,
|
||||
//是否添加杂点
|
||||
'useNoise' => true,
|
||||
// 验证码字体 不设置则随机
|
||||
'fontttf' => '',
|
||||
//背景颜色
|
||||
'bg' => [243, 251, 254],
|
||||
// 验证码图片高度
|
||||
'imageH' => 0,
|
||||
// 验证码图片宽度
|
||||
'imageW' => 0,
|
||||
// 验证码图片透明度
|
||||
'alpha' => 0,
|
||||
// 是否采用API模式生成
|
||||
'api' => true,
|
||||
|
||||
// 添加额外的验证码设置
|
||||
// verify => [
|
||||
// 'length'=>4,
|
||||
// ...
|
||||
//],
|
||||
];
|
||||
@@ -9,9 +9,9 @@ return [
|
||||
// SESSION_ID的提交变量,解决flash上传跨域
|
||||
'var_session_id' => '',
|
||||
// 驱动方式 支持file cache
|
||||
'type' => 'file',
|
||||
'type' => 'cache',
|
||||
// 存储连接标识 当type使用cache的时候有效
|
||||
'store' => null,
|
||||
'store' => 'redis',
|
||||
// 过期时间
|
||||
'expire' => 1440,
|
||||
// 前缀
|
||||
|
||||
Reference in New Issue
Block a user