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.
31 lines
910 B
31 lines
910 B
/** |
|
* @program: kicc-ui |
|
* @description: 菜单路由导航守卫 |
|
* 菜单路由参数保留一份,防止恶意修改参数 |
|
* @author: entfrm开发团队-王翔 |
|
* @create: 2022/4/9 |
|
*/ |
|
|
|
import type { Router } from 'vue-router'; |
|
import { configureDynamicParamsMenu } from '../helper/menuHelper'; |
|
import { Menu } from '../types'; |
|
import { usePermissionStoreWithOut } from '/@/store/modules/permission'; |
|
|
|
export function createParamMenuGuard(router: Router) { |
|
const permissionStore = usePermissionStoreWithOut(); |
|
router.beforeEach(async (to, _, next) => { |
|
// 过滤无名路由 |
|
if (!to.name) { |
|
next(); |
|
return; |
|
} |
|
// 检测是否菜单已建立 |
|
if (!permissionStore.getIsDynamicAddedRoute) { |
|
next(); |
|
return; |
|
} |
|
const menus: Menu[] = permissionStore.getMenuList; |
|
menus.forEach((item) => configureDynamicParamsMenu(item, to.params)); |
|
next(); |
|
}); |
|
}
|
|
|