Skip to content

Commit

Permalink
fix(app-search): exclude items by hideChildrenInMenu
Browse files Browse the repository at this point in the history
修复菜单搜索组件可能会显示被隐藏的子菜单的问题
  • Loading branch information
mynetfan committed Jul 5, 2021
1 parent faf5c9f commit 02d3dca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/Application/src/search/useMenuSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>,
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));
}
});
Expand Down
1 change: 1 addition & 0 deletions src/router/routes/modules/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const dashboard: AppRouteModule = {
meta: {
title: t('routes.dashboard.about'),
icon: 'simple-icons:about-dot-me',
// hideMenu: true,
},
},
],
Expand Down

0 comments on commit 02d3dca

Please sign in to comment.