@@ -27,6 +27,14 @@ export function fmtBytes(n: number): string {
|
||||
return `${(n / 2 ** (10 * i)).toFixed(1)} ${units[i]}`
|
||||
}
|
||||
|
||||
/** 金额展示:千分位 + 2 位小数,常见币种转符号前缀,其余保留币种码 */
|
||||
export function fmtMoney(n: number, currency = 'USD'): string {
|
||||
const sym: Record<string, string> = { USD: '$', EUR: '€', GBP: '£', JPY: '¥', CNY: '¥' }
|
||||
const s = n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
const p = sym[currency]
|
||||
return p ? p + s : `${currency} ${s}`.trim()
|
||||
}
|
||||
|
||||
/** OCID 中段省略:ocid1.instance.oc1..aaaa…mc25a */
|
||||
export function truncOcid(ocid: string, head = 24, tail = 6): string {
|
||||
if (!ocid || ocid.length <= head + tail + 1) return ocid
|
||||
|
||||
Reference in New Issue
Block a user