chore(permisssion): optimize logout

This commit is contained in:
pengYYY 2022-03-07 17:45:38 +08:00
parent ae3e021587
commit 732eb1b289
2 changed files with 2 additions and 8 deletions

View File

@ -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();
}
});
next();
return;
}

View File

@ -61,7 +61,6 @@ export const usePermissionStore = defineStore('permission', {
async initRoutes(roles: Array<unknown>) {
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);
});