10 lines
497 B
TypeScript
10 lines
497 B
TypeScript
/** 数字人版本展示格式化(module 13 task 261):MD5 截断展示;纯逻辑。 */
|
|
|
|
/** MD5 前 len 位(默认 12,对齐 admin)展示;空值回空串。 */
|
|
export function md5Short(md5: string | null | undefined, len = 12): string {
|
|
const text = typeof md5 === 'string' ? md5.trim() : ''
|
|
if (!text) return ''
|
|
const max = typeof len === 'number' && Number.isFinite(len) && len >= 1 ? Math.floor(len) : 12
|
|
return text.length <= max ? text : `${text.slice(0, max)}…`
|
|
}
|