feat: chat integration, tenant admin spec, backend chat service, miniprogram updates, DEMO moved to tmp, XCX-TEST removed, migrations & docs

This commit is contained in:
Neo
2026-03-20 09:02:10 +08:00
parent 3d2e5f8165
commit beb88d5bea
388 changed files with 6436 additions and 25458 deletions

View File

@@ -0,0 +1,65 @@
/**
* 金额 / 计数 / 百分比格式化工具
* 规范docs/miniprogram-dev/design-system/DISPLAY-STANDARDS.md
*/
/**
* 金额格式化
* ¥12,680 / -¥368 / ¥0 / --
* @param value 金额(元,整数)
*/
export function formatMoney(value: number | null | undefined): string {
if (value === null || value === undefined) return '--'
if (value === 0) return '¥0'
const abs = Math.round(Math.abs(value))
const formatted = abs.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
return value < 0 ? `${formatted}` : `¥${formatted}`
}
/**
* 计数格式化(带单位)
* 零值返回 '--'≥1000 加千分位
* @param value 数值
* @param unit 单位字符串,如 '笔' '次' '人'
*/
export function formatCount(
value: number | null | undefined,
unit: string,
): string {
if (value === null || value === undefined || value === 0) return '--'
const n =
value >= 1000
? value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
: String(value)
return `${n}${unit}`
}
/**
* 纯数字千分位格式化(无单位,用于非金额大数字)
* 零值返回 '--'
*/
export function formatNumber(value: number | null | undefined): string {
if (value === null || value === undefined || value === 0) return '--'
return value >= 1000
? value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
: String(value)
}
/**
* 百分比展示允许超过100%
* 保留1位小数零值返回 '0%';空值返回 '--'
*/
export function formatPercent(value: number | null | undefined): string {
if (value === null || value === undefined) return '--'
if (value === 0) return '0%'
return `${value.toFixed(1)}%`
}
/**
* 进度条 CSS 宽度字符串(截断至 [0, 100],防止溢出)
* 用法style="width: {{toProgressWidth(perfData.filledPct)}}"
*/
export function toProgressWidth(value: number | null | undefined): string {
if (value === null || value === undefined) return '0%'
return `${Math.min(100, Math.max(0, value)).toFixed(1)}%`
}