mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 02:00:22 +08:00
fix: fix menu permission failure
This commit is contained in:
parent
9abba7af3e
commit
b8353fe1f2
@ -6,6 +6,7 @@ import { transformMenuModule, flatMenus, getAllParentPath } from '/@/utils/helpe
|
||||
import { filter } from '/@/utils/helper/treeHelper';
|
||||
import router from '/@/router';
|
||||
import { PermissionModeEnum } from '/@/enums/appEnum';
|
||||
import { pathToRegexp } from 'path-to-regexp';
|
||||
|
||||
// ===========================
|
||||
// ==========module import====
|
||||
@ -106,9 +107,14 @@ export async function getFlatChildrenMenus(children: Menu[]) {
|
||||
// 通用过滤方法
|
||||
function basicFilter(routes: RouteRecordNormalized[]) {
|
||||
return (menu: Menu) => {
|
||||
const matchRoute = routes.find((route) => route.path === menu.path);
|
||||
const matchRoute = routes.find((route) => {
|
||||
if (route.meta && route.meta.carryParam) {
|
||||
return pathToRegexp(route.path).test(menu.path);
|
||||
}
|
||||
return route.path === menu.path;
|
||||
});
|
||||
|
||||
if (!matchRoute) return true;
|
||||
if (!matchRoute) return false;
|
||||
menu.icon = menu.icon || matchRoute.meta.icon;
|
||||
menu.meta = matchRoute.meta;
|
||||
return true;
|
||||
|
@ -102,6 +102,7 @@ export default {
|
||||
component: () => import('/@/views/demo/feat/tab-params/index.vue'),
|
||||
meta: {
|
||||
title: 'Tab带参',
|
||||
carryParam: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
4
src/router/types.d.ts
vendored
4
src/router/types.d.ts
vendored
@ -29,8 +29,10 @@ export interface RouteMeta {
|
||||
|
||||
// close loading
|
||||
afterCloseLoading?: boolean;
|
||||
|
||||
// Is it in the tab
|
||||
inTab?: boolean;
|
||||
// Carrying parameters
|
||||
carryParam?: boolean;
|
||||
}
|
||||
|
||||
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
||||
|
Loading…
Reference in New Issue
Block a user