update 优化token失效后跳转登录页的逻辑

This commit is contained in:
zk
2024-05-20 11:14:09 +08:00
parent 6ff0b25f1b
commit 60be7c4fe2
3 changed files with 23 additions and 4 deletions
+5 -1
View File
@@ -6,7 +6,7 @@ import { TOKEN_KEY } from '/@/enum/cacheEnum.ts';
import { useMessage } from '/@/hooks/web/useMessage.ts';
import { checkStatus } from '/@/api/checkStatus.ts';
import router from '/@/router';
import { getBaseLogin } from '/@/enum/pageEnum.ts';
import { getBaseLogin, toLoginByNowPath } from '/@/enum/pageEnum.ts';
const { createMessage, createErrorModal } = useMessage();
const { VITE_GLOB_API_URL } = getAppEnvConfig();
@@ -34,6 +34,10 @@ service.interceptors.response.use(
switch (error.response.data.code) {
case 401:
let path = getBaseLogin();
if (!path) {
path = toLoginByNowPath(router.currentRoute.value.path);
}
createMessage.warn(error.response.data.message);
router.replace({
path: path,
});