perf: 方法抽离
This commit is contained in:
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user