Files
Genarrative/packages/shared/src/utils/format.ts
T
2026-07-16 16:20:35 +08:00

16 lines
576 B
TypeScript

export function formatMudPointCount(value: number, compact = false) {
const normalizedValue = Math.max(0, Math.round(value));
if (compact && normalizedValue >= 100_000_000) {
return `${(normalizedValue / 100_000_000).toFixed(1)}亿`;
}
if (compact && normalizedValue >= 10_000) {
return `${(normalizedValue / 10_000).toFixed(1)}万`;
}
return normalizedValue.toLocaleString('zh-CN');
}
export function formatRechargePrice(priceCents: number) {
const yuan = priceCents / 100;
return ${Number.isInteger(yuan) ? yuan.toFixed(0) : yuan.toFixed(2)}`;
}