Files
new-api-key-usage/apps/web/src/utils/format.ts
T

24 lines
811 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 呈现层格式化(不做业务换算——换算责任在后端,契约公共约定 §5) */
/** 千分位整数;口径内精确显示,不四舍五入 */
export function formatInt(value: number | null | undefined): string {
if (value == null) return "—";
return value.toLocaleString("en-US");
}
/** quota 原值 + 美元双单位展示片段 */
export function formatQuotaDual(
quota: number | null | undefined,
quotaUsd: string | null | undefined,
): string {
if (quota == null) return "—";
const usd = quotaUsd ?? "—";
return `${formatInt(quota)}($${usd})`;
}
/** 支付金额:纯数字、无货币符号(R9 币种无关) */
export function formatPaidAmount(value: number | null | undefined): string {
if (value == null) return "—";
return String(value);
}