From 069175bf1648bc42371bbae58d56c9245ad8bbe0 Mon Sep 17 00:00:00 2001 From: kiki1373639299 Date: Fri, 7 Nov 2025 14:24:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B7=B7=E5=90=88?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E5=B7=A6=E4=BE=A7=E8=8F=9C=E5=8D=95=E6=B6=88=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #ID5HXD Co-authored-by: kiki1373639299 # message auto-generated for no-merge-commit merge: !13 merge menu-error into dev fix: 修复混合布局模式下详情页左侧菜单消失问题 Created-by: kiki1373639299 Commit-by: kiki1373639299 Merged-by: Charles_7c Description: ## PR 类型 - [ ] 新 feature - [X] Bug 修复 - [ ] 功能增强 - [ ] 文档变更 - [ ] 代码样式变更 - [ ] 重构 - [ ] 性能改进 - [ ] 单元测试 - [ ] CI/CD - [ ] 其他 ## PR 目的 ## 解决方案 修改 src/layout/LayoutMix.vue 中的 getLeftMenus 函数: - 优先从路由的 meta.activeMenu 获取菜单 key - 如果没有 activeMenu,则使用 path - 确保详情页能正确关联到父菜单并显示其子菜单 ## PR 测试 ## Changelog | 模块 | Changelog | Related issues | |-----|-----------| -------------- | | src/layout/LayoutMix.vue | src/layout/LayoutMix.vue:101-112: 重构 getLeftMenus 函数,优先使用 meta.activeMenu 作为菜单 key | Closes #ID5HXD | ## 其他信息 ## 提交前确认 - [X] PR 代码经过了完整测试,并且通过了代码规范检查 - [X] 已经完整填写 Changelog,并链接到了相关 issues - [X] PR 代码将要提交到 dev 分支 See merge request: continew/continew-admin-ui!13 --- src/layout/LayoutMix.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/layout/LayoutMix.vue b/src/layout/LayoutMix.vue index bd19f4c..3d158d7 100644 --- a/src/layout/LayoutMix.vue +++ b/src/layout/LayoutMix.vue @@ -98,8 +98,13 @@ const activeMenu = ref([]) // 左侧的菜单 const leftMenus = ref([]) // 获取左侧菜单 -const getLeftMenus = (key: string) => { - const arr = searchTree(cloneMenuRoutes, (i) => i.path === key, { children: 'children' }) +const getLeftMenus = (currentRoute?: RouteRecordRaw, key?: string) => { + // 优先从路由的 meta.activeMenu 获取key,如果没有则使用path + const menuKey = currentRoute + ? (currentRoute.meta?.activeMenu as string) || currentRoute.path + : key || '' + + const arr = searchTree(cloneMenuRoutes, (i) => i.path === menuKey, { children: 'children' }) const rootPath = arr.length ? arr[0].path : '' const obj = cloneMenuRoutes.find((i) => i.path === rootPath) activeMenu.value = obj ? [obj.path] : [''] @@ -111,7 +116,7 @@ const onMenuItemClick = (key: string) => { window.open(key) return } - setTimeout(() => getLeftMenus(key)) + setTimeout(() => getLeftMenus(undefined, key)) const obj = topMenus.value.find((i) => i.path === key) if (obj && obj.redirect === 'noRedirect') return router.push({ path: key }) @@ -119,9 +124,9 @@ const onMenuItemClick = (key: string) => { watch( () => route.path, - (newPath) => { + () => { nextTick(() => { - getLeftMenus(newPath) + getLeftMenus(route) }) }, { immediate: true },