提交
This commit is contained in:
1 parent
b45ce2c32c
commit
a5210a6a9e
30 files changed
+11989
-5917
No files matched your search
@@ -58,6 +58,8 @@ export const SIDEBAR_MENU_ICON_MAP: Record<string, string> = {
|
||||
|
||||
// ── 系统 ──
|
||||
SystemManage: 'ri:settings-3-line',
|
||||
SystemInfo: 'ri:information-line',
|
||||
SystemTemp: 'ri:inbox-archive-line',
|
||||
Tenant: 'ri:building-line',
|
||||
Dict: 'ri:book-2-line',
|
||||
Menu: 'ri:menu-line',
|
||||
|
||||
@@ -11,11 +11,25 @@ export interface PortalHomeCardItem {
|
||||
menuCode?: string
|
||||
}
|
||||
|
||||
/** 一级模块下按二级菜单分组的一行 */
|
||||
export interface PortalHomeGroup {
|
||||
/** 二级菜单 path;叶子直属合并组用空串 */
|
||||
groupPath: string
|
||||
/** 二级菜单标题;空串表示不展示分组标题(一级下的叶子页) */
|
||||
groupTitle: string
|
||||
cards: PortalHomeCardItem[]
|
||||
/** 为 true 时不渲染二级标题(CRM 等扁平二级叶子) */
|
||||
hideTitle?: boolean
|
||||
}
|
||||
|
||||
export interface PortalHomeSection {
|
||||
/** 一级模块 path */
|
||||
modulePath: string
|
||||
moduleTitle: string
|
||||
/** 扁平卡片(收藏 / 角标 / 检索共用) */
|
||||
cards: PortalHomeCardItem[]
|
||||
/** 按二级菜单分行展示 */
|
||||
groups: PortalHomeGroup[]
|
||||
}
|
||||
|
||||
/** 首页菜单目录条目(含拼音检索元数据) */
|
||||
@@ -75,40 +89,92 @@ function toCard(item: AppRouteRecord): PortalHomeCardItem | null {
|
||||
}
|
||||
}
|
||||
|
||||
/** 从一级模块收集可点卡片(跳过不可导航二级标题) */
|
||||
export function collectCardsForModule(module: AppRouteRecord): PortalHomeCardItem[] {
|
||||
/** 从一级模块按二级收集分组与扁平卡片(跳过不可导航二级标题) */
|
||||
export function collectGroupsForModule(module: AppRouteRecord): {
|
||||
groups: PortalHomeGroup[]
|
||||
cards: PortalHomeCardItem[]
|
||||
} {
|
||||
const l2List = filterSidebarRoutes(module.children || [])
|
||||
const groups: PortalHomeGroup[] = []
|
||||
const cards: PortalHomeCardItem[] = []
|
||||
const seen = new Set<string>()
|
||||
/** 一级下直接挂的叶子页,按菜单顺序合并为无标题行,避免「产品管理 / 产品管理」重复 */
|
||||
let pendingFlat: PortalHomeCardItem[] | null = null
|
||||
|
||||
const push = (item: AppRouteRecord) => {
|
||||
const pushUnique = (item: AppRouteRecord): PortalHomeCardItem | null => {
|
||||
const card = toCard(item)
|
||||
if (!card || seen.has(card.path)) return
|
||||
if (!card || seen.has(card.path)) return null
|
||||
seen.add(card.path)
|
||||
cards.push(card)
|
||||
return card
|
||||
}
|
||||
|
||||
const flushFlat = () => {
|
||||
if (!pendingFlat?.length) {
|
||||
pendingFlat = null
|
||||
return
|
||||
}
|
||||
groups.push({
|
||||
groupPath: '',
|
||||
groupTitle: '',
|
||||
cards: pendingFlat,
|
||||
hideTitle: true
|
||||
})
|
||||
pendingFlat = null
|
||||
}
|
||||
|
||||
for (const l2 of l2List) {
|
||||
const links = resolveMegaPanelL3Links(l2)
|
||||
for (const link of links) {
|
||||
push(link)
|
||||
}
|
||||
const hasKids = filterSidebarRoutes(l2.children || []).length > 0
|
||||
if (hasKids && isSidebarNavigableRoute(l2)) {
|
||||
push(l2)
|
||||
const links = resolveMegaPanelL3Links(l2)
|
||||
|
||||
// 无真实子级:侧栏里的「二级」实际是一级下的叶子页(如 CRM 产品管理)
|
||||
if (!hasKids) {
|
||||
if (!pendingFlat) pendingFlat = []
|
||||
for (const link of links) {
|
||||
const card = pushUnique(link)
|
||||
if (card) pendingFlat.push(card)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
flushFlat()
|
||||
const groupCards: PortalHomeCardItem[] = []
|
||||
for (const link of links) {
|
||||
const card = pushUnique(link)
|
||||
if (card) groupCards.push(card)
|
||||
}
|
||||
if (isSidebarNavigableRoute(l2)) {
|
||||
const card = pushUnique(l2)
|
||||
if (card) groupCards.push(card)
|
||||
}
|
||||
if (!groupCards.length) continue
|
||||
groups.push({
|
||||
groupPath: String(l2.path || ''),
|
||||
groupTitle: routeTitle(l2),
|
||||
cards: groupCards
|
||||
})
|
||||
}
|
||||
return cards
|
||||
flushFlat()
|
||||
return { groups, cards }
|
||||
}
|
||||
|
||||
/** 从一级模块收集可点卡片(跳过不可导航二级标题) */
|
||||
export function collectCardsForModule(module: AppRouteRecord): PortalHomeCardItem[] {
|
||||
return collectGroupsForModule(module).cards
|
||||
}
|
||||
|
||||
export function collectPortalHomeSections(menuList: AppRouteRecord[]): PortalHomeSection[] {
|
||||
const tops = filterPortalTopModules(menuList)
|
||||
return tops
|
||||
.map((mod) => ({
|
||||
modulePath: String(mod.path || ''),
|
||||
moduleTitle: routeTitle(mod),
|
||||
cards: collectCardsForModule(mod)
|
||||
}))
|
||||
.map((mod) => {
|
||||
const { groups, cards } = collectGroupsForModule(mod)
|
||||
return {
|
||||
modulePath: String(mod.path || ''),
|
||||
moduleTitle: routeTitle(mod),
|
||||
cards,
|
||||
groups
|
||||
}
|
||||
})
|
||||
.filter((s) => s.cards.length > 0)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user