fix(app-search): exclude items by hideChildrenInMenu

修复菜单搜索组件可能会显示被隐藏的子菜单的问题
This commit is contained in:
无木 2021-07-05 14:50:41 +08:00
parent faf5c9fd7e
commit 02d3dca57e
2 changed files with 4 additions and 3 deletions

View File

@ -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));
}
});

View File

@ -22,6 +22,7 @@ const dashboard: AppRouteModule = {
meta: {
title: t('routes.dashboard.about'),
icon: 'simple-icons:about-dot-me',
// hideMenu: true,
},
},
],