mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-23 20:00:19 +08:00
feat(route): add hidePathForChildren
in meta
添加`hidePathForChildren`选项用于在子菜单中隐藏本级path
This commit is contained in:
parent
72ac240f28
commit
d52b0de83e
@ -9,10 +9,6 @@ export function getAllParentPath<T = Recordable>(treeData: T[], path: string) {
|
|||||||
return (menuList || []).map((item) => item.path);
|
return (menuList || []).map((item) => item.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPlainPath(path: string) {
|
|
||||||
return path.indexOf(':') === -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function joinParentPath(menus: Menu[], parentPath = '') {
|
function joinParentPath(menus: Menu[], parentPath = '') {
|
||||||
for (let index = 0; index < menus.length; index++) {
|
for (let index = 0; index < menus.length; index++) {
|
||||||
const menu = menus[index];
|
const menu = menus[index];
|
||||||
@ -24,7 +20,7 @@ function joinParentPath(menus: Menu[], parentPath = '') {
|
|||||||
menu.path = `${parentPath}/${menu.path}`;
|
menu.path = `${parentPath}/${menu.path}`;
|
||||||
}
|
}
|
||||||
if (menu?.children?.length) {
|
if (menu?.children?.length) {
|
||||||
joinParentPath(menu.children, isPlainPath(menu.path) ? menu.path : parentPath);
|
joinParentPath(menu.children, menu.meta?.hidePathForChildren ? parentPath : menu.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,7 @@ const feat: AppRouteModule = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: t('routes.demo.feat.tab'),
|
title: t('routes.demo.feat.tab'),
|
||||||
carryParam: true,
|
carryParam: true,
|
||||||
|
hidePathForChildren: true,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
3
types/vue-router.d.ts
vendored
3
types/vue-router.d.ts
vendored
@ -33,6 +33,9 @@ declare module 'vue-router' {
|
|||||||
// Never show in menu
|
// Never show in menu
|
||||||
hideMenu?: boolean;
|
hideMenu?: boolean;
|
||||||
isLink?: boolean;
|
isLink?: boolean;
|
||||||
|
// only build for Menu
|
||||||
ignoreRoute?: boolean;
|
ignoreRoute?: boolean;
|
||||||
|
// Hide path for children
|
||||||
|
hidePathForChildren?: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user