提交
This commit is contained in:
1 parent
ca6aca2b14
commit
f70dc26206
63 files changed
+589912
-9127
No files matched your search
@@ -0,0 +1,10 @@
|
||||
/** 运输计划:内置山峡/云栋客户(该侧合同可免) */
|
||||
export const PL_INTERNAL_CUSTOMER_NAMES = [
|
||||
'安庆市山峡化工有限公司',
|
||||
'安徽云栋化工有限公司'
|
||||
] as const
|
||||
|
||||
export function isPlInternalCustomerName(name?: string | null): boolean {
|
||||
const n = (name || '').trim()
|
||||
return (PL_INTERNAL_CUSTOMER_NAMES as readonly string[]).includes(n)
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
import {
|
||||
filterPortalTopModules,
|
||||
resolveMegaPanelL3Links
|
||||
} from '@/utils/router/portal-menu'
|
||||
import {
|
||||
filterSidebarRoutes,
|
||||
isSidebarNavigableRoute
|
||||
} from '@/utils/router/sidebar-menu-filter'
|
||||
import { filterPortalTopModules, resolveMegaPanelL3Links } from '@/utils/router/portal-menu'
|
||||
import { filterSidebarRoutes, isSidebarNavigableRoute } from '@/utils/router/sidebar-menu-filter'
|
||||
|
||||
export interface PortalHomeCardItem {
|
||||
path: string
|
||||
@@ -21,10 +16,51 @@ export interface PortalHomeSection {
|
||||
cards: PortalHomeCardItem[]
|
||||
}
|
||||
|
||||
/** 首页菜单目录条目(含拼音检索元数据) */
|
||||
export interface PortalHomeMenuItem extends PortalHomeCardItem {
|
||||
modulePath: string
|
||||
moduleTitle: string
|
||||
/** 菜单全拼(小写、去空格与符号) */
|
||||
py: string
|
||||
/** 菜单首字母缩写(小写) */
|
||||
abbr: string
|
||||
/** 拼音首字母 A–Z,其它为 # */
|
||||
letter: string
|
||||
/** 模块名全拼 */
|
||||
modulePy: string
|
||||
/** 模块名首字母缩写 */
|
||||
moduleAbbr: string
|
||||
}
|
||||
|
||||
function routeTitle(item: AppRouteRecord): string {
|
||||
return String(item.meta?.title ?? item.name ?? item.path ?? '')
|
||||
}
|
||||
|
||||
function normalizeSearchKey(s: string): string {
|
||||
return String(s || '')
|
||||
.toLowerCase()
|
||||
.replace(/[\s'·・\-_/]/g, '')
|
||||
}
|
||||
|
||||
function buildPinyinMeta(title: string): { py: string; abbr: string; letter: string } {
|
||||
const text = String(title || '').trim()
|
||||
if (!text) {
|
||||
return { py: '', abbr: '', letter: '#' }
|
||||
}
|
||||
const py = normalizeSearchKey(pinyin(text, { toneType: 'none', type: 'string', separator: '' }))
|
||||
const abbr = normalizeSearchKey(
|
||||
pinyin(text, {
|
||||
pattern: 'first',
|
||||
toneType: 'none',
|
||||
type: 'string',
|
||||
separator: ''
|
||||
})
|
||||
)
|
||||
const first = (abbr[0] || py[0] || '#').toUpperCase()
|
||||
const letter = /[A-Z]/.test(first) ? first : '#'
|
||||
return { py, abbr, letter }
|
||||
}
|
||||
|
||||
function toCard(item: AppRouteRecord): PortalHomeCardItem | null {
|
||||
const path = String(item.meta?.activePath || item.path || '')
|
||||
if (!path) return null
|
||||
@@ -72,6 +108,55 @@ export function collectPortalHomeSections(menuList: AppRouteRecord[]): PortalHom
|
||||
.filter((s) => s.cards.length > 0)
|
||||
}
|
||||
|
||||
/** 扁平化首页菜单并附带拼音检索字段 */
|
||||
export function flattenPortalHomeMenus(menuList: AppRouteRecord[]): PortalHomeMenuItem[] {
|
||||
const sections = collectPortalHomeSections(menuList)
|
||||
const out: PortalHomeMenuItem[] = []
|
||||
const seen = new Set<string>()
|
||||
|
||||
for (const sec of sections) {
|
||||
const moduleMeta = buildPinyinMeta(sec.moduleTitle)
|
||||
for (const card of sec.cards) {
|
||||
if (seen.has(card.path)) continue
|
||||
seen.add(card.path)
|
||||
const meta = buildPinyinMeta(card.title)
|
||||
out.push({
|
||||
...card,
|
||||
modulePath: sec.modulePath,
|
||||
moduleTitle: sec.moduleTitle,
|
||||
py: meta.py,
|
||||
abbr: meta.abbr,
|
||||
letter: meta.letter,
|
||||
modulePy: moduleMeta.py,
|
||||
moduleAbbr: moduleMeta.abbr
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** 中文名 / 模块名 / 全拼 / 首字母 匹配 */
|
||||
export function matchPortalHomeMenuItem(item: PortalHomeMenuItem, query: string): boolean {
|
||||
const q = String(query || '').trim()
|
||||
if (!q) return true
|
||||
if (item.title.includes(q) || item.moduleTitle.includes(q)) return true
|
||||
const nq = normalizeSearchKey(q)
|
||||
if (!nq) return true
|
||||
return (
|
||||
item.py.includes(nq) ||
|
||||
item.abbr.includes(nq) ||
|
||||
item.modulePy.includes(nq) ||
|
||||
item.moduleAbbr.includes(nq)
|
||||
)
|
||||
}
|
||||
|
||||
/** 标题内高亮查询子串(仅字面匹配) */
|
||||
export function highlightPortalHomeTitle(title: string, query: string): string {
|
||||
const q = String(query || '').trim()
|
||||
if (!q || !title.includes(q)) return title
|
||||
return title.split(q).join(`<mark>${q}</mark>`)
|
||||
}
|
||||
|
||||
/** 在全部分区中按 path 查找卡片元数据 */
|
||||
export function findHomeCardByPath(
|
||||
sections: PortalHomeSection[],
|
||||
|
||||
Reference in new issue
Block a user