Commit 02d3dca57efedc1322ae38e3f432cf1f6c2cf839
1 parent
faf5c9fd
fix(app-search): exclude items by `hideChildrenInMenu`
修复菜单搜索组件可能会显示被隐藏的子菜单的问题
Showing
2 changed files
with
4 additions
and
3 deletions
src/components/Application/src/search/useMenuSearch.ts
@@ -64,15 +64,15 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>, | @@ -64,15 +64,15 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>, | ||
64 | function handlerSearchResult(filterMenu: Menu[], reg: RegExp, parent?: Menu) { | 64 | function handlerSearchResult(filterMenu: Menu[], reg: RegExp, parent?: Menu) { |
65 | const ret: SearchResult[] = []; | 65 | const ret: SearchResult[] = []; |
66 | filterMenu.forEach((item) => { | 66 | filterMenu.forEach((item) => { |
67 | - const { name, path, icon, children, hideMenu } = item; | ||
68 | - if (!hideMenu && reg.test(name) && !children?.length) { | 67 | + const { name, path, icon, children, hideMenu, meta } = item; |
68 | + if (!hideMenu && reg.test(name) && (!children?.length || meta?.hideChildrenInMenu)) { | ||
69 | ret.push({ | 69 | ret.push({ |
70 | name: parent?.name ? `${parent.name} > ${name}` : name, | 70 | name: parent?.name ? `${parent.name} > ${name}` : name, |
71 | path, | 71 | path, |
72 | icon, | 72 | icon, |
73 | }); | 73 | }); |
74 | } | 74 | } |
75 | - if (Array.isArray(children) && children.length) { | 75 | + if (!meta?.hideChildrenInMenu && Array.isArray(children) && children.length) { |
76 | ret.push(...handlerSearchResult(children, reg, item)); | 76 | ret.push(...handlerSearchResult(children, reg, item)); |
77 | } | 77 | } |
78 | }); | 78 | }); |
src/router/routes/modules/about.ts
@@ -22,6 +22,7 @@ const dashboard: AppRouteModule = { | @@ -22,6 +22,7 @@ const dashboard: AppRouteModule = { | ||
22 | meta: { | 22 | meta: { |
23 | title: t('routes.dashboard.about'), | 23 | title: t('routes.dashboard.about'), |
24 | icon: 'simple-icons:about-dot-me', | 24 | icon: 'simple-icons:about-dot-me', |
25 | + // hideMenu: true, | ||
25 | }, | 26 | }, |
26 | }, | 27 | }, |
27 | ], | 28 | ], |