refactor(menu): added 'SimpleMenu' component. Solve the menu stuck problem #199 #190 #191

This commit is contained in:
vben 2021-01-17 23:02:13 +08:00
parent ff2b12b409
commit 7279c0a7b5
4 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@
- 修复 `TableAction`图标问题
- 修复菜单折叠按钮丢失问题
- 修复菜单相关问题
## 2.0.0-rc.16 (2020-01-12)

View File

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

View File

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

View File

@ -75,6 +75,8 @@ export interface Menu {
meta?: Partial<RouteMeta>;
tag?: MenuTag;
hideMenu?: boolean;
}
export interface MenuModule {