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); } });