fix(permission store): clear routes when logout (#545)

fix #541
This commit is contained in:
ngyyuusora 2023-06-20 23:33:11 +08:00 committed by GitHub
parent 9d8bf86059
commit 8194b3d253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,9 +37,13 @@ export const usePermissionStore = defineStore('permission', {
}
},
async restoreRoutes() {
this.removeRoutes.forEach((item: RouteRecordRaw) => {
router.addRoute(item);
// 不需要在此额外调用initRoutes更新侧边导肮内容在登录后asyncRoutes为空会调用
this.asyncRoutes.forEach((item: RouteRecordRaw) => {
if (item.name) {
router.removeRoute(item.name);
}
});
this.asyncRoutes = [];
},
},
});