This commit is contained in:
zlwu committed 2026-05-20 09:28:36 +08:00
1 parent e6072457fd
commit be4fab78e1
578 files changed
+174415 -214

No files matched your search

+43 -22
View File
@@ -65,6 +65,29 @@
}
const panelTitleIconByText: Array<[RegExp, string]> = [
[/(租户)/, 'auto-title-tenant'],
[/(字典)/, 'auto-title-dict'],
[/(角色)/, 'auto-title-role'],
[/(菜单)/, 'auto-title-menu'],
[/(职位)/, 'auto-title-post'],
[/(站点)/, 'auto-title-location'],
[/(单位)/, 'auto-title-unit'],
[/(快递)/, 'auto-title-express'],
[/(组织)/, 'auto-title-dept'],
[/(SOP)/i, 'auto-title-file'],
[/(捐赠|协议)/, 'auto-title-file'],
[/(缴费|退费)/, 'auto-title-calc'],
[/(接收|检查项|样本|编码)/, 'auto-title-file'],
[/(审核|记录)/, 'auto-title-file'],
[/(客户|公司|机构|医院)/, 'auto-title-user'],
[/(采集|地区|洁净|库位)/, 'auto-title-location'],
[/(预约)/, 'auto-title-operation'],
[/(工单)/, 'auto-title-receipt'],
[/(流程|待办|已办|申请|请假|执行)/, 'auto-title-operation'],
[/(耗材|试剂)/, 'auto-title-box'],
[/(工艺|路线)/, 'auto-title-settings'],
[/(规格|价格|体系|渠道|项目)/, 'auto-title-category'],
[/(类型)/, 'auto-title-category'],
[/(任务|调度)/, 'auto-title-operation'],
[/(区域)/, 'auto-title-location'],
[/(用户|账号)/, 'auto-title-user'],
@@ -74,46 +97,44 @@
[/(订单)/, 'auto-title-receipt'],
[/(发票)/, 'auto-title-file'],
[/(询价|报价)/, 'auto-title-quote'],
[/(结算)/, 'auto-title-calc']
[/(结算)/, 'auto-title-calc'],
[/(入口|概览|选择)/, 'auto-title-menu']
]
const panelTitleClassList = panelTitleIconByText.map(([, cls]) => cls)
const panelTitleBarClass = 'title-bar-heading'
const panelTitleBarTextRules: RegExp[] = [
/(数据概览|快捷菜单|分类列表|单位列表|商品列表|参数列表|用户列表|租户列表|区域列表|区域与询报价概览|报价管理|订单列表|最新订单|待结算订单|结算单记录|配送任务列表|预警列表|订单设置|客服设置|请求列表|近30日趋势|今日各区域|组织|组织管理|角色列表|菜单列表|字典类型|字典数据|站点列表|职位列表|快递公司列表|流程配置|流程列表|待办列表|已办列表|申请列表|客户列表|细胞样本类型列表|采集地区列表|采集协议号列表|样本编码列表|医院列表|协议单列表|审核记录列表|缴费确认列表|退费确认列表|分期预警列表|请假列表|洁净室列表|库位树|预约列表|缴费信息列表|样本接收列表|接收检查项列表|公司列表|项目列表|工单列表|任务列表|类型列表|规格列表|价格列表|体系列表|渠道列表|机构列表|耗材列表|试剂列表|SOP列表|工艺列表|路线列表|耗材包列表)/
const panelTitleClassList = [
...panelTitleIconByText.map(([, cls]) => cls),
'auto-title-list'
]
const panelTitleBarClass = 'title-bar-heading'
const panelTitleHeadingSelector =
'.page-container .panel-top h2, .page-container .panel-top h3, .page-container .storage-content-header h3, .page-container .storage-aside__head h2, .page-container .user-dept-aside__head h2, .console-container .panel-top h2'
const refreshPanelTitleIcons = () => {
const headings = document.querySelectorAll<HTMLHeadingElement>(
'.page-container .panel-top h2, .console-container .panel-top h2'
)
const headings = document.querySelectorAll<HTMLHeadingElement>(panelTitleHeadingSelector)
headings.forEach((h2) => {
const text = (h2.textContent || '').replace(/\s+/g, '')
const useBar = panelTitleBarTextRules.some((rule) => rule.test(text))
headings.forEach((heading) => {
const text = (heading.textContent || '').replace(/\s+/g, '')
const preferPanelIcon = Boolean(
heading.closest('.page-container, .console-container')
)
if (useBar) {
h2.querySelector('.title-ic')?.remove()
panelTitleClassList.forEach((className) => h2.classList.remove(className))
h2.classList.add(panelTitleBarClass)
return
}
if (!preferPanelIcon) return
h2.classList.remove(panelTitleBarClass)
heading.classList.remove(panelTitleBarClass)
// 已手写 title-ic(例如 delivery-demo)则不干预
if (h2.querySelector('.title-ic')) return
if (heading.querySelector('.title-ic')) return
// 确保存在容器
const span = document.createElement('span')
span.className = 'title-ic'
span.setAttribute('aria-hidden', 'true')
h2.prepend(span)
heading.prepend(span)
// 根据标题文本匹配图标类型
panelTitleClassList.forEach((className) => h2.classList.remove(className))
panelTitleClassList.forEach((className) => heading.classList.remove(className))
const matched = panelTitleIconByText.find(([rule]) => rule.test(text))
if (matched) h2.classList.add(matched[1])
heading.classList.add(matched ? matched[1] : 'auto-title-list')
})
}