Files
Genarrative/packages/shared/src/utils/format.ts
T
k88936 125927e0e8 Ai game creator app home sidebar (#86)
![shotmd-1784186268.jpg](/attachments/c828773c-4f1a-4654-b76d-c944b82ec023)
![shotmd-1784186877.jpg](/attachments/f1782ba3-245a-40c1-8caa-cbd7e4cce74b)
![shotmd-1784186948-compressed.webp](/attachments/f3d02ac3-db7a-439b-9a84-7aceefad9048)
TODO: 补充说明书链接

Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/86
Co-authored-by: 王德宇 <kvtodev@outlook.com>
Co-committed-by: 王德宇 <kvtodev@outlook.com>
2026-07-20 15:03:23 +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)}`;
}