perf: 方法抽离

This commit is contained in:
rd
2025-07-09 16:23:05 +08:00
parent 5432b465ce
commit d903230c14

View File

@ -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) => { menuList.forEach((item) => {
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
item.children.forEach((child: any) => { item.children.forEach((child: any) => {
const matchedRoute = appRoutes.filter((route: any) => child.pathNames.includes(route.name)); pushAllowAccessRoutes(child.pathNames);
this.allowAccessRoutes.push(...matchedRoute);
}); });
} else { } else {
const matchedRoute = appRoutes.filter((route: any) => item.pathNames.includes(route.name)); pushAllowAccessRoutes(item.pathNames);
this.allowAccessRoutes.push(...matchedRoute);
} }
}); });