From dc85bb0afe329555414975d8101a888c338fac54 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Sat, 8 Feb 2025 11:18:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=89=80=E6=9C=89=E8=B7=AF=E7=94=B1=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=B3=A8=E9=94=80=E5=90=8E=E9=87=8D=E6=96=B0=E7=99=BB=E9=99=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/permission.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index ed93ee5b..6a8e532b 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -51,15 +51,16 @@ export const usePermissionStore = defineStore("permission", () => { * 重置路由 */ const resetRouter = () => { - // 清空本地存储的路由和菜单数据 - routes.value = []; - mixedLayoutLeftRoutes.value = []; - // 从 Vue Router 中移除所有动态注册的路由 - router.getRoutes().forEach((route) => { - if (route.name) { + // 从 router 实例中移除动态路由 + routes.value.forEach((route) => { + if (route.name && !constantRoutes.find((r) => r.name === route.name)) { router.removeRoute(route.name); } }); + + // 清空本地存储的路由和菜单数据 + routes.value = []; + mixedLayoutLeftRoutes.value = []; isRoutesLoaded.value = false; };