Implement compression quota refunds and admin manual subscription

This commit is contained in:
2025-12-19 23:28:32 +08:00
commit 11f48fd3dd
106 changed files with 27848 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
export function formatBytes(bytes: number): string {
if (!Number.isFinite(bytes) || bytes <= 0) return '0 B'
const units = ['B', 'KB', 'MB', 'GB']
let value = bytes
let unit = 0
while (value >= 1024 && unit < units.length - 1) {
value /= 1024
unit += 1
}
const digits = unit === 0 ? 0 : unit === 1 ? 1 : 2
return `${value.toFixed(digits)} ${units[unit]}`
}
export function formatCents(amountCents: number, currency: string): string {
const amount = (amountCents ?? 0) / 100
const cc = (currency ?? 'CNY').toUpperCase()
return new Intl.NumberFormat('zh-CN', {
style: 'currency',
currency: cc,
maximumFractionDigits: 2,
}).format(amount)
}