Ruoyi是否启用验证码由后台appsettings.json决定

This commit is contained in:
Po
2024-10-14 16:49:33 +08:00
parent 7049175827
commit b59dfbc3fd
4 changed files with 7 additions and 4 deletions

View File

@@ -4,5 +4,7 @@
{
public Guid Uuid { get; set; } = Guid.Empty;
public byte[] Img { get; set; }
public bool IsEnableCaptcha { get; set; }
}
}

View File

@@ -157,7 +157,8 @@ namespace Yi.Framework.Rbac.Application.Services
{
var uuid = _guidGenerator.Create();
var captcha = _captcha.Generate(uuid.ToString());
return new CaptchaImageDto { Img = captcha.Bytes, Uuid = uuid };
var enableCaptcha = _rbacOptions.EnableCaptcha;
return new CaptchaImageDto { Img = captcha.Bytes, Uuid = uuid,IsEnableCaptcha= enableCaptcha };
}
/// <summary>

View File

@@ -113,7 +113,7 @@ const loginRules = {
const codeUrl = ref("");
const loading = ref(false);
// 验证码开关
const captchaEnabled = ref(true);
const captchaEnabled = ref(false);
// 注册开关
const register = ref(false);
const redirect = ref(undefined);
@@ -157,7 +157,7 @@ function handleLogin() {
function getCode() {
getCodeImg().then(res => {
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled;
captchaEnabled.value = res.data.isEnableCaptcha === undefined ? true : res.data.isEnableCaptcha;
if (captchaEnabled.value) {
codeUrl.value = "data:image/gif;base64," + res.data.img;
loginForm.value.uuid = res.data.uuid;

View File

@@ -142,7 +142,7 @@ function handleRegister() {
function getCode() {
getCodeImg().then(res => {
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled;
captchaEnabled.value = res.data.isEnableCaptcha === undefined ? true : res.data.isEnableCaptcha;
if (captchaEnabled.value) {
codeUrl.value = "data:image/gif;base64," + res.img;
registerForm.value.uuid = res.uuid;