Skip to content

Commit

Permalink
fix(app-search): exclude hidden items
Browse files Browse the repository at this point in the history
修复菜单搜索组件可能会显示被隐藏的菜单的问题
  • Loading branch information
mynetfan committed Jul 5, 2021
1 parent d5d5c4b commit faf5c9f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 🐛 Bug Fixes

- **Table** 修复滚动条样式问题
- **AppSearch** 修复可能会搜索隐藏菜单的问题
- **其它** 修复菜单默认折叠的配置不起作用的问题

## 2.6.0(2021-07-04)
Expand Down
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 @@ -55,7 +55,7 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>,
}
const reg = createSearchReg(unref(keyword));
const filterMenu = filter(menuList, (item) => {
return reg.test(item.name);
return reg.test(item.name) && !item.hideMenu;
});
searchResult.value = handlerSearchResult(filterMenu, reg);
activeIndex.value = 0;
Expand All @@ -64,8 +64,8 @@ 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 } = item;
if (reg.test(name) && !children?.length) {
const { name, path, icon, children, hideMenu } = item;
if (!hideMenu && reg.test(name) && !children?.length) {
ret.push({
name: parent?.name ? `${parent.name} > ${name}` : name,
path,
Expand Down
2 changes: 1 addition & 1 deletion src/router/routes/modules/demo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const setup: AppRouteModule = {
meta: {
orderNo: 90000,
hideChildrenInMenu: true,
icon: 'simple-icons:about-dot-me',
icon: 'whh:paintroll',
title: t('routes.demo.setup.page'),
},
children: [
Expand Down

0 comments on commit faf5c9f

Please sign in to comment.