From 732eb1b2891513a70e0c7f3606b750d9b2782a87 Mon Sep 17 00:00:00 2001 From: pengYYY Date: Mon, 7 Mar 2022 17:45:38 +0800 Subject: [PATCH] chore(permisssion): optimize logout --- src/permission.ts | 8 ++------ src/store/modules/permission.ts | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index 4c3bf78..03af970 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -18,12 +18,8 @@ router.beforeEach(async (to, from, next) => { const { token } = userStore; if (token) { if (to.path === '/login') { - setTimeout(() => { - if (userStore.token) { - userStore.logout(); - permissionStore.restore(); - } - }); + userStore.logout(); + permissionStore.restore(); next(); return; } diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 88e555d..bc2c6a0 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -61,7 +61,6 @@ export const usePermissionStore = defineStore('permission', { async initRoutes(roles: Array) { let accessedRouters = []; - // 路由做减法,优化登陆后的跳转时间 let removeRoutes = []; // special token if (roles.includes('all')) { @@ -82,7 +81,6 @@ export const usePermissionStore = defineStore('permission', { }); }, async restore() { - // 复原route,保证在登陆状态时路由全量 this.removeRoutes.forEach((item: RouteRecordRaw) => { router.addRoute(item); });