From d903230c14acd56e70c8c9a626b66bff941bbc88 Mon Sep 17 00:00:00 2001 From: rd <1344903914@qq.com> Date: Wed, 9 Jul 2025 16:23:05 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B9=E6=B3=95=E6=8A=BD=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/modules/user/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/stores/modules/user/index.ts b/src/stores/modules/user/index.ts index 6e798b8..a560cdb 100644 --- a/src/stores/modules/user/index.ts +++ b/src/stores/modules/user/index.ts @@ -90,15 +90,18 @@ export const useUserStore = defineStore('user', { } }); + const pushAllowAccessRoutes = (pathNames: string[]) => { + const matchedRoute = appRoutes.filter((route: any) => pathNames.includes(route.name)); + this.allowAccessRoutes.push(...matchedRoute); + }; + menuList.forEach((item) => { if (item.children && item.children.length > 0) { item.children.forEach((child: any) => { - const matchedRoute = appRoutes.filter((route: any) => child.pathNames.includes(route.name)); - this.allowAccessRoutes.push(...matchedRoute); + pushAllowAccessRoutes(child.pathNames); }); } else { - const matchedRoute = appRoutes.filter((route: any) => item.pathNames.includes(route.name)); - this.allowAccessRoutes.push(...matchedRoute); + pushAllowAccessRoutes(item.pathNames); } });