You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
705 B
26 lines
705 B
import type { Router } from 'vue-router' |
|
import { configureDynamicParamsMenu } from '../helper/menuHelper' |
|
import type { Menu } from '../types' |
|
import { usePermissionStoreWithOut } from '@/store/modules/permission' |
|
|
|
export function createParamMenuGuard(router: Router) { |
|
const permissionStore = usePermissionStoreWithOut() |
|
router.beforeEach((to, _, next) => { |
|
// filter no name route |
|
if (!to.name) { |
|
next() |
|
return |
|
} |
|
|
|
// menu has been built. |
|
if (!permissionStore.getIsDynamicAddedRoute) { |
|
next() |
|
return |
|
} |
|
|
|
const menus: Menu[] = permissionStore.getBackMenuList |
|
menus.forEach(item => configureDynamicParamsMenu(item, to.params)) |
|
|
|
next() |
|
}) |
|
}
|
|
|