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) => {
|
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user