diff --git a/jeecgboot-vue3/src/router/helper/menuHelper.ts b/jeecgboot-vue3/src/router/helper/menuHelper.ts index 561c23a94c5..ab2a798a76e 100644 --- a/jeecgboot-vue3/src/router/helper/menuHelper.ts +++ b/jeecgboot-vue3/src/router/helper/menuHelper.ts @@ -31,7 +31,7 @@ function findMenuPath(treeData: T[], path: string, matchHide: bo if(!matchHide && n.hideMenu) { return false; } - return n.path === path + return n.path.split('?')[0] === path.split('?')[0] }) as Menu[]; } @@ -95,7 +95,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi name: title, hideMenu, alwaysShow:node.alwaysShow||false, - path: node.path, + path: node.meta?.menuPath || node.path, originComponent: node.originComponent, ...(node.redirect ? { redirect: node.redirect } : {}), }; diff --git a/jeecgboot-vue3/src/router/helper/routeHelper.ts b/jeecgboot-vue3/src/router/helper/routeHelper.ts index 9e49806371c..f67081407f5 100644 --- a/jeecgboot-vue3/src/router/helper/routeHelper.ts +++ b/jeecgboot-vue3/src/router/helper/routeHelper.ts @@ -79,6 +79,11 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { if (!item.component && item.meta?.frameSrc) { item.component = 'IFRAME'; } + if (item.path?.startsWith('/') && item.path.includes('?')) { + item.meta = item.meta || {}; + item.meta.menuPath = item.path; + item.path = item.path.split('?')[0]; + } let { component, name } = item; const { children } = item; if (component) { diff --git a/jeecgboot-vue3/src/router/menus/index.ts b/jeecgboot-vue3/src/router/menus/index.ts index 97b719957fa..36134eaa966 100644 --- a/jeecgboot-vue3/src/router/menus/index.ts +++ b/jeecgboot-vue3/src/router/menus/index.ts @@ -104,18 +104,19 @@ export async function getChildrenMenus(parentPath: string) { function basicFilter(routes: RouteRecordNormalized[]) { return (menu: Menu) => { + const menuBasePath = menu.path.split('?')[0]; const matchRoute = routes.find((route) => { if (isUrl(menu.path)) return true; if (route.meta?.carryParam) { - return pathToRegexp(route.path).test(menu.path); + return pathToRegexp(route.path).test(menuBasePath); } - const isSame = route.path === menu.path; + const isSame = route.path === menuBasePath; if (!isSame) return false; if (route.meta?.ignoreAuth) return true; - return isSame || pathToRegexp(route.path).test(menu.path); + return isSame || pathToRegexp(route.path).test(menuBasePath); }); if (!matchRoute) return false;