From 02d3dca57efedc1322ae38e3f432cf1f6c2cf839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E6=9C=A8?= Date: Mon, 5 Jul 2021 14:50:41 +0800 Subject: [PATCH] fix(app-search): exclude items by `hideChildrenInMenu` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复菜单搜索组件可能会显示被隐藏的子菜单的问题 --- src/components/Application/src/search/useMenuSearch.ts | 6 +++--- src/router/routes/modules/about.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Application/src/search/useMenuSearch.ts b/src/components/Application/src/search/useMenuSearch.ts index c7441d9c3a7..9101b4ac942 100644 --- a/src/components/Application/src/search/useMenuSearch.ts +++ b/src/components/Application/src/search/useMenuSearch.ts @@ -64,15 +64,15 @@ export function useMenuSearch(refs: Ref, scrollWrap: Ref, function handlerSearchResult(filterMenu: Menu[], reg: RegExp, parent?: Menu) { const ret: SearchResult[] = []; filterMenu.forEach((item) => { - const { name, path, icon, children, hideMenu } = item; - if (!hideMenu && reg.test(name) && !children?.length) { + const { name, path, icon, children, hideMenu, meta } = item; + if (!hideMenu && reg.test(name) && (!children?.length || meta?.hideChildrenInMenu)) { ret.push({ name: parent?.name ? `${parent.name} > ${name}` : name, path, icon, }); } - if (Array.isArray(children) && children.length) { + if (!meta?.hideChildrenInMenu && Array.isArray(children) && children.length) { ret.push(...handlerSearchResult(children, reg, item)); } }); diff --git a/src/router/routes/modules/about.ts b/src/router/routes/modules/about.ts index 03cb42511c3..31b0c0621e9 100644 --- a/src/router/routes/modules/about.ts +++ b/src/router/routes/modules/about.ts @@ -22,6 +22,7 @@ const dashboard: AppRouteModule = { meta: { title: t('routes.dashboard.about'), icon: 'simple-icons:about-dot-me', + // hideMenu: true, }, }, ],