diff --git a/src/api/auth.ts b/src/api/auth.ts index eb904d87..1ac19be0 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -35,6 +35,16 @@ class AuthAPI { method: "get", }); } + + /** + * 获取验证码规则 + */ + static getCaptchaRule() { + return request({ + url: `${AUTH_BASE_URL}/captcha/unable`, + method: "get", + }); + } } export default AuthAPI; diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 7222319e..1c58a41b 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -107,7 +107,7 @@ - +
(); +// 是否关闭验证码 +const closeCaptcha = ref(false); const logo = ref(new URL(`../../assets/logo.png`, import.meta.url).href); @@ -341,8 +343,17 @@ const setLoginCredentials = (username: string, password: string) => { loginData.value.password = password; }; +function getCaptchaRule() { + AuthAPI.getCaptchaRule().then((data) => { + closeCaptcha.value = data; + if (!closeCaptcha.value) { + getCaptcha(); + } + }); +} + onMounted(() => { - getCaptcha(); + getCaptchaRule(); });