diff --git a/src/utils/money.ts b/src/utils/money.ts index f837839..892e33a 100644 --- a/src/utils/money.ts +++ b/src/utils/money.ts @@ -75,16 +75,26 @@ export const Money = { }, /** - * Format money for display with currency symbol + * Format money for display with currency symbol (Standard v7.0) */ format(value: number | string, currency: string = 'CNY'): string { - const num = new Decimal(value).toDecimalPlaces(2).toNumber(); - const symbol = CURRENCY_SYMBOLS[currency] || currency; - const formatted = num.toLocaleString('zh-CN', { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - }); - return `${symbol}${formatted}`; + const num = new Decimal(value).toNumber(); + try { + return new Intl.NumberFormat('zh-CN', { + style: 'currency', + currency: currency, + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }).format(num); + } catch (e) { + // Fallback for invalid currency codes + const symbol = CURRENCY_SYMBOLS[currency] || currency; + const formatted = num.toLocaleString('zh-CN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }); + return `${symbol}${formatted}`; + } }, /**