update 优化token失效后跳转登录页的逻辑
This commit is contained in:
+5
-1
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user