From 1ff420c61ac17b401596d8c55dc14c46b0438814 Mon Sep 17 00:00:00 2001 From: kun <1422840143@qq.com> Date: Wed, 5 Jul 2023 18:32:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 4 +++- src/routers/index.ts | 3 ++- src/routers/modules/dynamicRouter.ts | 6 ++++-- src/views/loading/index.vue | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 65b15e4..53babaf 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -80,8 +80,10 @@ class RequestHttp { if (error.message.indexOf("Network Error") !== -1) ElMessage.error("网络错误!请您稍后重试"); if (error.message.indexOf("Request failed with status code 401") !== -1) { // ElMessage.error("登录已过期,请重新登录"); + // ElMessage.error("登录信息异常,请刷新或重新登录!"); globalStore.resetStore(); - router.replace(LOGIN_URL); + // router.replace(LOGIN_URL); + router.replace("/load"); } // 根据响应的错误状态码,做不同的处理 // if (response) checkStatus(response.status); diff --git a/src/routers/index.ts b/src/routers/index.ts index 9505778..359111f 100644 --- a/src/routers/index.ts +++ b/src/routers/index.ts @@ -56,7 +56,8 @@ router.beforeEach(async (to, from, next) => { if (ROUTER_WHITE_LIST.includes(to.path)) return next(); // 5.判断是否有 Token,没有重定向到 login - if (!globalStore.token) return next({ path: LOGIN_URL, replace: true }); + // if (!globalStore.token) return next({ path: LOGIN_URL, replace: true }); + if (!globalStore.token) return next({ path: "load", replace: true }); // 6.如果没有菜单列表,就重新请求菜单列表并添加动态路由 const authStore = AuthStore(); diff --git a/src/routers/modules/dynamicRouter.ts b/src/routers/modules/dynamicRouter.ts index b13f052..5875a54 100644 --- a/src/routers/modules/dynamicRouter.ts +++ b/src/routers/modules/dynamicRouter.ts @@ -30,7 +30,8 @@ export const initDynamicRouter = async (params?: any) => { }); globalStore.resetStore(); - router.replace(LOGIN_URL); + // router.replace(LOGIN_URL); + router.replace("/load"); return Promise.reject("No permission"); } @@ -65,7 +66,8 @@ export const initDynamicRouter = async (params?: any) => { } catch (error) { // 💢 当按钮 || 菜单请求出错时,重定向到登陆页 globalStore.resetStore(); - router.replace(LOGIN_URL); + // router.replace(LOGIN_URL); + router.replace("/load"); return Promise.reject(error); } }; diff --git a/src/views/loading/index.vue b/src/views/loading/index.vue index a7d254c..b872bc4 100644 --- a/src/views/loading/index.vue +++ b/src/views/loading/index.vue @@ -53,7 +53,8 @@ const tokenIdentify = async () => { globalStore.moduleId = "1670603312504918018"; } } else { - ElMessage.error("登录错误!"); + // ElMessage.error("登录信息异常,请刷新或重新登录!"); + return; } console.log(res); };