forked from ChaiHao/BPOS-MVP
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
/**
|
|
* 数据域的人读短名 —— 导航一枚钮/一个页签只放得下 2-3 个字。
|
|
*
|
|
* 数据按**经营对象**四分(docs/产品设计.md 附录):
|
|
* 项目 = 每一单的流转单据;客户 / 情报 / 供应商 = 沉淀资产。
|
|
* 字典之外的域回落到键的最后一段(截 4 字符)—— 新域没配短名时,先有个能认的名字。
|
|
*/
|
|
export const DOMAIN_SHORT: Readonly<Record<string, string>> = {
|
|
project: '项目',
|
|
customer: '客户',
|
|
intel: '情报',
|
|
supplier: '供应商',
|
|
};
|
|
|
|
/** 业务序:项目(每天看的)→ 客户 → 情报 → 供应商 —— 按经营视角排,不按字母 */
|
|
const DOMAIN_ORDER = ['project', 'customer', 'intel', 'supplier'];
|
|
|
|
export function sortDomains(domains: readonly string[]): string[] {
|
|
return [...domains].sort((a, b) => {
|
|
const ia = DOMAIN_ORDER.indexOf(a);
|
|
const ib = DOMAIN_ORDER.indexOf(b);
|
|
// 字典外的域排在已知域之后,彼此按键序稳定
|
|
if (ia === -1 && ib === -1) return a.localeCompare(b);
|
|
if (ia === -1) return 1;
|
|
if (ib === -1) return -1;
|
|
return ia - ib;
|
|
});
|
|
}
|
|
|
|
export function domainShort(domain: string): string {
|
|
const hit = DOMAIN_SHORT[domain];
|
|
if (hit !== undefined) return hit;
|
|
const tail = domain.split('_').at(-1) ?? domain;
|
|
return tail.length <= 4 ? tail : tail.slice(0, 4);
|
|
}
|