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 Guid Uuid { get; set; } = Guid.Empty;
public byte[] Img { get; set; } 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 uuid = _guidGenerator.Create();
var captcha = _captcha.Generate(uuid.ToString()); 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> /// <summary>

View File

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

View File

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