提交 0419a070 编写于 作者: V vben

feat(menu): add mixSideTrigger setting

上级 799a694b
## Wip
### ✨ Features
- 新增`mixSideTrigger`配置。用于配置左侧混合模式菜单打开方式。可选`hover`,默认`click`
## 2.0.0-rc.15 (2020-12-31)
### ✨ 表格破坏性更新
......
......@@ -33,6 +33,8 @@ const getSplit = computed(() => unref(getMenuSetting).split);
const getMenuBgColor = computed(() => unref(getMenuSetting).bgColor);
const getMixSideTrigger = computed(() => unref(getMenuSetting).mixSideTrigger);
const getCanDrag = computed(() => unref(getMenuSetting).canDrag);
const getAccordion = computed(() => unref(getMenuSetting).accordion);
......@@ -145,5 +147,6 @@ export function useMenuSetting() {
getIsMixMode,
getIsMixSidebar,
getCloseMixSidebarOnChange,
getMixSideTrigger,
};
}
......@@ -10,6 +10,7 @@
open: openMenu,
},
]"
v-bind="getMenuEvents"
>
<AppLogo :showTitle="false" :class="`${prefixCls}-logo`" />
<ScrollContainer>
......@@ -23,7 +24,7 @@
]"
v-for="item in menuModules"
:key="item.path"
@click="hanldeModuleClick(item.path)"
v-bind="getItemEvents(item)"
>
<MenuTag :item="item" :showTitle="false" :isHorizontal="false" />
<g-icon
......@@ -112,6 +113,7 @@
getCanDrag,
getCloseMixSidebarOnChange,
getMenuTheme,
getMixSideTrigger,
} = useMenuSetting();
const { title } = useGlobSetting();
......@@ -125,6 +127,16 @@
}
);
const getMenuEvents = computed(() => {
return unref(getMixSideTrigger) === 'hover'
? {
onMouseleave: () => {
openMenu.value = false;
},
}
: {};
});
const getShowDragBar = computed(() => unref(getCanDrag));
onMounted(async () => {
......@@ -139,11 +151,13 @@
}
});
async function hanldeModuleClick(path: string) {
async function hanldeModuleClick(path: string, hover = false) {
const children = await getChildrenMenus(path);
if (unref(activePath) === path) {
openMenu.value = !unref(openMenu);
if (!hover) {
openMenu.value = !unref(openMenu);
}
if (!unref(openMenu)) {
setActive();
}
......@@ -178,6 +192,17 @@
setActive();
}
function getItemEvents(item: Menu) {
if (unref(getMixSideTrigger) === 'hover') {
return {
onMouseenter: () => hanldeModuleClick(item.path, true),
};
}
return {
onClick: () => hanldeModuleClick(item.path),
};
}
return {
t,
prefixCls,
......@@ -194,6 +219,8 @@
title,
openMenu,
getMenuTheme,
getItemEvents,
getMenuEvents,
};
},
});
......
......@@ -108,6 +108,8 @@ const setting: ProjectConfig = {
accordion: true,
// Switch page to close menu
closeMixSidebarOnChange: false,
// Module opening method ‘click’ |'hover'
mixSideTrigger: 'hover',
},
// Multi-label
......
......@@ -20,6 +20,7 @@ export interface MenuSetting {
accordion: boolean;
closeMixSidebarOnChange: boolean;
collapsedShowTitle: boolean;
mixSideTrigger: 'click' | 'hover';
}
export interface MultiTabsSetting {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册