From 8194b3d2533ec5e23d6115231a2331fb86ceb7be Mon Sep 17 00:00:00 2001 From: ngyyuusora Date: Tue, 20 Jun 2023 23:33:11 +0800 Subject: [PATCH] fix(permission store): clear routes when logout (#545) fix #541 --- src/store/modules/permission.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 94892f6..b0e81b3 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -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 = []; }, }, });