mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 13:18:40 +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;
|
const { token } = userStore;
|
||||||
if (token) {
|
if (token) {
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
setTimeout(() => {
|
|
||||||
if (userStore.token) {
|
|
||||||
userStore.logout();
|
userStore.logout();
|
||||||
permissionStore.restore();
|
permissionStore.restore();
|
||||||
}
|
|
||||||
});
|
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ export const usePermissionStore = defineStore('permission', {
|
||||||
async initRoutes(roles: Array<unknown>) {
|
async initRoutes(roles: Array<unknown>) {
|
||||||
let accessedRouters = [];
|
let accessedRouters = [];
|
||||||
|
|
||||||
// 路由做减法,优化登陆后的跳转时间
|
|
||||||
let removeRoutes = [];
|
let removeRoutes = [];
|
||||||
// special token
|
// special token
|
||||||
if (roles.includes('all')) {
|
if (roles.includes('all')) {
|
||||||
|
@ -82,7 +81,6 @@ export const usePermissionStore = defineStore('permission', {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async restore() {
|
async restore() {
|
||||||
// 复原route,保证在登陆状态时路由全量
|
|
||||||
this.removeRoutes.forEach((item: RouteRecordRaw) => {
|
this.removeRoutes.forEach((item: RouteRecordRaw) => {
|
||||||
router.addRoute(item);
|
router.addRoute(item);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user