Skip to content

Commit

Permalink
refactor(menu): added 'SimpleMenu' component. Solve the menu stuck pr…
Browse files Browse the repository at this point in the history
…oblem #199 #190 #191
  • Loading branch information
anncwb committed Jan 17, 2021
1 parent ff2b12b commit 7279c0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- 修复 `TableAction`图标问题
- 修复菜单折叠按钮丢失问题
- 修复菜单相关问题

## 2.0.0-rc.16 (2020-01-12)

Expand Down
2 changes: 1 addition & 1 deletion src/components/SimpleMenu/src/SimpleSubMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
const { prefixCls } = useDesign('simple-menu');
const getShowMenu = computed(() => {
return !props.item.meta?.hideMenu;
return !props.item?.hideMenu;
});
const getIcon = computed(() => props.item?.icon);
Expand Down
10 changes: 9 additions & 1 deletion src/router/helper/menuHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export function transformMenuModule(menuModule: MenuModule): Menu {
export function transformRouteToMenu(routeModList: AppRouteModule[]) {
const cloneRouteModList = cloneDeep(routeModList);
const routeList: AppRouteRecordRaw[] = [];

// cloneRouteModList = filter(cloneRouteModList, (node) => {
// if (Reflect.has(node?.meta ?? {}, 'hideMenu')) {
// return !node?.meta.hideMenu;
// }
// return true;
// });
cloneRouteModList.forEach((item) => {
if (item.meta?.single) {
const realItem = item?.children?.[0];
Expand All @@ -55,13 +62,14 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
});
return treeMap(routeList, {
conversion: (node: AppRouteRecordRaw) => {
const { meta: { title, icon } = {} } = node;
const { meta: { title, icon, hideMenu = false } = {} } = node;

!isUrl(node.path) && joinParentPath(routeList, node);
return {
name: title,
icon,
path: node.path,
hideMenu,
};
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/router/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export interface Menu {
meta?: Partial<RouteMeta>;

tag?: MenuTag;

hideMenu?: boolean;
}

export interface MenuModule {
Expand Down

0 comments on commit 7279c0a

Please sign in to comment.