From 978058c5432915546d33aa65d2827cfadabdd713 Mon Sep 17 00:00:00 2001 From: Sisyphus Date: Fri, 10 Jul 2026 10:27:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(F006-W18):=20=E9=9D=A2=E5=8C=85=E5=B1=91?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=AE=8C=E6=95=B4=E8=B7=AF=E5=BE=84(?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0>=E4=B8=80=E7=BA=A7=E7=9B=AE?= =?UTF-8?q?=E5=BD=95>...>=E6=9C=AB=E7=BA=A7=E8=8F=9C=E5=8D=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: AppLayout.vue 面包屑写死两级(工作台 + route.meta.title), 省略了中间的父级目录层级。 修法: 加 breadcrumbItems computed, 从当前 route.path 在菜单树 (menuStore.list) DFS 追溯父级链, 返回完整路径标题数组。 - 列表页: 工作台 > 父目录 > ... > 末级菜单 - 详情页: 工作台 > 父目录 > ... > meta.title - 首页/未命中: 仅工作台 部署: dist rsync + docker rebuild + scp src + curl 200 验证 --- src/components/AppLayout/AppLayout.vue | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/components/AppLayout/AppLayout.vue b/src/components/AppLayout/AppLayout.vue index 4e06020..17e2771 100644 --- a/src/components/AppLayout/AppLayout.vue +++ b/src/components/AppLayout/AppLayout.vue @@ -60,6 +60,46 @@ function isActive(path: string): boolean { return path === '/' ? route.path === '/' : route.path.startsWith(path) } +/** + * 面包屑: 从当前 route.path 在菜单树里 DFS 追溯完整父级链 + * 返回 [一级目录, ..., 末级菜单], 不含"工作台"前缀(template 里单独拼) + * 找不到时 fallback 到 route.meta.title + */ +const breadcrumbItems = computed(() => { + const currentPath = route.path + // 工作台首页不显示中间层级 + if (currentPath === '/' || currentPath === '/dashboard') return [] + // DFS 找父级链 + function findChain(items: MenuItem[], target: string, chain: MenuItem[]): boolean { + for (const item of items) { + if (item.path === target || (item.path !== '/' && target.startsWith(item.path))) { + chain.push(item) + return true + } + if (item.children?.length) { + chain.push(item) + if (findChain(item.children, target, chain)) return true + chain.pop() + } + } + return false + } + const chain: MenuItem[] = [] + findChain(menuList.value, currentPath, chain) + const metaTitle = route.meta?.title as string | undefined + if (chain.length) { + const titles: string[] = chain.map(i => i.title) + const last = chain[chain.length - 1] + if (last.path !== currentPath) { + // 详情页: 命中的是父前缀, 追加 meta.title + return metaTitle ? [...titles, metaTitle] : titles + } + return titles + } + // 菜单树没命中 (如 /inquiry/:id 详情页), 用 meta.title 兜底 + return metaTitle ? [metaTitle] : [] +}) + const PARENT_GROUP: Record = { '概览': '概览', '业务': '业务', @@ -329,7 +369,7 @@ onMounted(loadBadges) 工作台 - {{ route.meta?.title || '' }} + {{ item }}