20 lines
732 B
TypeScript
20 lines
732 B
TypeScript
import type { App } from 'vue'
|
|
import routes from 'src/routes'
|
|
import { indexStore } from 'lib/stores'
|
|
const store = indexStore();
|
|
const resource = store.$state.kwargs.resource || [];
|
|
|
|
export default function BeforeMount(app: App<Element>) {
|
|
const resourcePaths = resource.map((item: any) => item.path);
|
|
routes.forEach((route: any) => {
|
|
if (route && route.children) {
|
|
route.children.forEach((child: any) => {
|
|
const path = route.path + '/' + child.path;
|
|
child.meta.hidden = !resourcePaths.includes(path)
|
|
})
|
|
if(route.meta) {
|
|
route.meta.hidden = route.children.every((child: any) => child.meta.hidden);
|
|
}
|
|
}
|
|
})
|
|
} |