From 8514dcada44a1634265936f00c28ede4c1e8486e Mon Sep 17 00:00:00 2001 From: liweiyi <190785909@qq.com> Date: Wed, 25 Jun 2025 18:49:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chestnut-ui/src/views/login.vue | 2 +- chestnut-ui/src/views/register.vue | 36 +++++++++--------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/chestnut-ui/src/views/login.vue b/chestnut-ui/src/views/login.vue index bd61628f..322aaac6 100644 --- a/chestnut-ui/src/views/login.vue +++ b/chestnut-ui/src/views/login.vue @@ -128,7 +128,7 @@ export default { this.loginForm.captcha = data; }, handleLogin() { - if (!this.loginForm.captcha) { + if (this.captchaConfig.enabled && !this.loginForm.captcha) { this.$modal.msgError(this.$t('Login.CaptchaRuleTip')); return; } diff --git a/chestnut-ui/src/views/register.vue b/chestnut-ui/src/views/register.vue index ee5f5095..26a0891e 100644 --- a/chestnut-ui/src/views/register.vue +++ b/chestnut-ui/src/views/register.vue @@ -30,9 +30,8 @@ - - - + + import { getLoginCaptchaConfig, register } from "@/api/login"; -import SliderCaptcha from './components/captcha/slider' import MathCaptcha from './components/captcha/math' import TextCaptcha from './components/captcha/text' @@ -115,28 +113,14 @@ export default { this.captchaConfig = res.data; }); }, - handleSliderCaptchaSuccess(data) { - this.registerForm.captcha = { - type: this.captchaConfig.type, - token: data.token, - data: data.captcha - } - }, - handleMathCaptchaSuccess(data) { - this.registerForm.captcha = { - type: this.captchaConfig.type, - token: data.token, - data: data.captcha - } - }, - handleTextCaptchaSuccess(data) { - this.registerForm.captcha = { - type: this.captchaConfig.type, - token: data.token, - data: data.captcha - } + handleCaptchaSuccess(data) { + this.registerForm.captcha = data; }, handleRegister() { + if (this.captchaConfig.enabled && !this.registerForm.captcha) { + this.$modal.msgError(this.$t('Login.CaptchaRuleTip')); + return; + } this.$refs.registerForm.validate(valid => { if (valid) { this.loading = true; @@ -150,8 +134,8 @@ export default { }).catch(() => {}); }).catch(() => { this.loading = false; - if (this.captchaEnabled) { - this.getCode(); + if (this.captchaConfig.enabled) { + this.$refs[this.captchaConfig.type+'Captcha'].reloadCaptcha(); } }) }