ref : 重构令牌管理逻辑,,统一状态码识别

This commit is contained in:
TsMask
2025-04-27 17:23:33 +08:00
parent f76311cf1b
commit 2de9788373
23 changed files with 229 additions and 253 deletions

View File

@@ -5,7 +5,7 @@ import { message } from 'ant-design-vue/es';
import { reactive, onMounted, computed, toRaw } from 'vue';
import useUserStore from '@/store/modules/user';
import useAppStore from '@/store/modules/app';
import { getCaptchaImage } from '@/api/login';
import { getCaptchaImage } from '@/api/auth';
import { useRouter, useRoute } from 'vue-router';
import useI18n from '@/hooks/useI18n';
import useLayoutStore from '@/store/modules/layout';
@@ -75,21 +75,28 @@ function fnFinish() {
function fnGetCaptcha() {
if (state.captchaClick) return;
state.captchaClick = true;
getCaptchaImage().then(res => {
state.captchaClick = false;
if (res.code != RESULT_CODE_SUCCESS) {
message.warning(`${res.msg}`, 3);
return;
}
state.captcha.enabled = Boolean(res.captchaEnabled);
if (state.captcha.enabled) {
state.captcha.codeImg = res.img;
state.from.uuid = res.uuid;
if (res.text) {
state.from.code = res.text;
getCaptchaImage()
.then(res => {
if (res.code !== RESULT_CODE_SUCCESS) {
message.warning({
content: `${res.msg}`,
duration: 3,
});
return;
}
}
});
const { enabled, img, uuid } = res.data;
state.captcha.enabled = Boolean(enabled);
if (state.captcha.enabled) {
state.captcha.codeImg = img;
state.from.uuid = uuid;
}
if (res.data?.text) {
state.from.code = res.data.text;
}
})
.finally(() => {
state.captchaClick = false;
});
}
// 判断是否有背景地址