This commit is contained in:
2025-08-19 17:30:51 +08:00
parent fd44965f8a
commit 353c72c602
74 changed files with 10575 additions and 44 deletions

View File

@@ -3,19 +3,25 @@
namespace app\admin\model;
use think\Model;
use think\captcha\facade\Captcha as thinkCaptcha;
use Webman\Captcha\CaptchaBuilder;
use support\Request;
class SysCaptcha extends Model
{
public static function getCode($uuid)
public static function getCode($uuid, $request)
{
$code_data = thinkCaptcha::create('czg');
// 初始化验证码类
$builder = new CaptchaBuilder;
// 生成验证码
$builder->build();
// 获得验证码图片二进制数据
$img_content = $builder->inline();
// 保存至数据库
self::create([
'uuid' => $uuid,
'code' => $code_data['code'],
'expire_time' => date('Y-m-d H:i:s', time() + config('captcha.expire_time')),
'code' => $builder->getPhrase(),
'expire_time' => date('Y-m-d H:i:s', time() + 600),
]);
return ['img' => $code_data['img']];
return ['img' => $img_content];
}
}