mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 10:28:24 +08:00
chore(permisssion): optimize logout
This commit is contained in:
parent
ae3e021587
commit
732eb1b289
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user