admin_new P0+P1 全批次合并 (84 commits) #2

Merged
direv merged 85 commits from develop into main 2026-08-07 11:27:17 +08:00
Showing only changes of commit 978058c543 - Show all commits

View File

@ -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<string[]>(() => {
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<string, string> = {
'概览': '概览',
'业务': '业务',
@ -329,7 +369,7 @@ onMounted(loadBadges)
</div>
<el-breadcrumb separator=">" class="rr-topbar-breadcrumb">
<el-breadcrumb-item :to="{ path: '/' }">工作台</el-breadcrumb-item>
<el-breadcrumb-item>{{ route.meta?.title || '' }}</el-breadcrumb-item>
<el-breadcrumb-item v-for="item in breadcrumbItems" :key="item">{{ item }}</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="rr-topbar-right">