Commit cad021c34b71fa109640af75a0c2b72179e9e257
1 parent
5ceeefd1
fix(menu): fix mix-menu incorrect jumping in `hover` mode
修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由
Showing
2 changed files
with
21 additions
and
16 deletions
CHANGELOG.zh_CN.md
... | ... | @@ -8,12 +8,14 @@ |
8 | 8 | - **TableAction** 仅在 action.tooltip 存在的情况下 才包裹 Tooltip 组件 |
9 | 9 | - **BasicUpload** 修复处理非`array`值时报错的问题 |
10 | 10 | - **Form** 修复`FormItem`的`suffix`插槽样式问题 |
11 | +- **Menu** | |
12 | + - 修复左侧混合菜单的悬停触发逻辑 | |
13 | + - 修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题 | |
14 | + - 修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由 | |
11 | 15 | - **其它** |
12 | 16 | - 修复菜单默认折叠的配置不起作用的问题 |
13 | 17 | - 修复`safari`浏览器报错导致网站打不开 |
14 | 18 | - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题 |
15 | - - 修复左侧混合菜单的悬停触发逻辑 | |
16 | - - 修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题 | |
17 | 19 | |
18 | 20 | ### 🎫 Chores |
19 | 21 | ... | ... |
src/layouts/default/sider/MixSider.vue
... | ... | @@ -63,7 +63,7 @@ |
63 | 63 | </div> |
64 | 64 | <ScrollContainer :class="`${prefixCls}-menu-list__content`"> |
65 | 65 | <SimpleMenu |
66 | - :items="chilrenMenus" | |
66 | + :items="childrenMenus" | |
67 | 67 | :theme="getMenuTheme" |
68 | 68 | mixSider |
69 | 69 | @menuClick="handleMenuClick" |
... | ... | @@ -114,7 +114,7 @@ |
114 | 114 | setup() { |
115 | 115 | let menuModules = ref<Menu[]>([]); |
116 | 116 | const activePath = ref(''); |
117 | - const chilrenMenus = ref<Menu[]>([]); | |
117 | + const childrenMenus = ref<Menu[]>([]); | |
118 | 118 | const openMenu = ref(false); |
119 | 119 | const dragBarRef = ref<ElRef>(null); |
120 | 120 | const sideRef = ref<ElRef>(null); |
... | ... | @@ -150,7 +150,7 @@ |
150 | 150 | |
151 | 151 | const getIsFixed = computed(() => { |
152 | 152 | /* eslint-disable-next-line */ |
153 | - mixSideHasChildren.value = unref(chilrenMenus).length > 0; | |
153 | + mixSideHasChildren.value = unref(childrenMenus).length > 0; | |
154 | 154 | const isFixed = unref(getMixSideFixed) && unref(mixSideHasChildren); |
155 | 155 | if (isFixed) { |
156 | 156 | /* eslint-disable-next-line */ |
... | ... | @@ -209,9 +209,8 @@ |
209 | 209 | } |
210 | 210 | |
211 | 211 | // Process module menu click |
212 | - async function hanldeModuleClick(path: string, hover = false) { | |
212 | + async function handleModuleClick(path: string, hover = false) { | |
213 | 213 | const children = await getChildrenMenus(path); |
214 | - | |
215 | 214 | if (unref(activePath) === path) { |
216 | 215 | if (!hover) { |
217 | 216 | if (!unref(openMenu)) { |
... | ... | @@ -233,12 +232,12 @@ |
233 | 232 | } |
234 | 233 | |
235 | 234 | if (!children || children.length === 0) { |
236 | - go(path); | |
237 | - chilrenMenus.value = []; | |
235 | + if (!hover) go(path); | |
236 | + childrenMenus.value = []; | |
238 | 237 | closeMenu(); |
239 | 238 | return; |
240 | 239 | } |
241 | - chilrenMenus.value = children; | |
240 | + childrenMenus.value = children; | |
242 | 241 | } |
243 | 242 | |
244 | 243 | // Set the currently active menu and submenu |
... | ... | @@ -253,14 +252,14 @@ |
253 | 252 | if (p) { |
254 | 253 | const children = await getChildrenMenus(p); |
255 | 254 | if (setChildren) { |
256 | - chilrenMenus.value = children; | |
255 | + childrenMenus.value = children; | |
257 | 256 | |
258 | 257 | if (unref(getMixSideFixed)) { |
259 | 258 | openMenu.value = children.length > 0; |
260 | 259 | } |
261 | 260 | } |
262 | 261 | if (children.length === 0) { |
263 | - chilrenMenus.value = []; | |
262 | + childrenMenus.value = []; | |
264 | 263 | } |
265 | 264 | } |
266 | 265 | } |
... | ... | @@ -278,11 +277,15 @@ |
278 | 277 | function getItemEvents(item: Menu) { |
279 | 278 | if (unref(getMixSideTrigger) === 'hover') { |
280 | 279 | return { |
281 | - onMouseenter: () => hanldeModuleClick(item.path, true), | |
280 | + onMouseenter: () => handleModuleClick(item.path, true), | |
281 | + onClick: async () => { | |
282 | + const children = await getChildrenMenus(item.path); | |
283 | + if (item.path && (!children || children.length === 0)) go(item.path); | |
284 | + }, | |
282 | 285 | }; |
283 | 286 | } |
284 | 287 | return { |
285 | - onClick: () => hanldeModuleClick(item.path), | |
288 | + onClick: () => handleModuleClick(item.path), | |
286 | 289 | }; |
287 | 290 | } |
288 | 291 | |
... | ... | @@ -303,9 +306,9 @@ |
303 | 306 | t, |
304 | 307 | prefixCls, |
305 | 308 | menuModules, |
306 | - hanldeModuleClick, | |
309 | + handleModuleClick: handleModuleClick, | |
307 | 310 | activePath, |
308 | - chilrenMenus, | |
311 | + childrenMenus: childrenMenus, | |
309 | 312 | getShowDragBar, |
310 | 313 | handleMenuClick, |
311 | 314 | getMenuStyle, | ... | ... |