Commit d52b0de83e69f7505c28e6f59ec84bbe526ecd0d
1 parent
72ac240f
feat(route): add `hidePathForChildren` in `meta`
添加`hidePathForChildren`选项用于在子菜单中隐藏本级path
Showing
3 changed files
with
5 additions
and
5 deletions
src/router/helper/menuHelper.ts
... | ... | @@ -9,10 +9,6 @@ export function getAllParentPath<T = Recordable>(treeData: T[], path: string) { |
9 | 9 | return (menuList || []).map((item) => item.path); |
10 | 10 | } |
11 | 11 | |
12 | -function isPlainPath(path: string) { | |
13 | - return path.indexOf(':') === -1; | |
14 | -} | |
15 | - | |
16 | 12 | function joinParentPath(menus: Menu[], parentPath = '') { |
17 | 13 | for (let index = 0; index < menus.length; index++) { |
18 | 14 | const menu = menus[index]; |
... | ... | @@ -24,7 +20,7 @@ function joinParentPath(menus: Menu[], parentPath = '') { |
24 | 20 | menu.path = `${parentPath}/${menu.path}`; |
25 | 21 | } |
26 | 22 | if (menu?.children?.length) { |
27 | - joinParentPath(menu.children, isPlainPath(menu.path) ? menu.path : parentPath); | |
23 | + joinParentPath(menu.children, menu.meta?.hidePathForChildren ? parentPath : menu.path); | |
28 | 24 | } |
29 | 25 | } |
30 | 26 | } | ... | ... |
src/router/routes/modules/demo/feat.ts
types/vue-router.d.ts