feat: 添加使用量统计和数据分析功能

This commit is contained in:
fawney19
2025-12-11 17:52:32 +08:00
parent 9c850c4f84
commit cc4e28ad16
7 changed files with 459 additions and 7 deletions

View File

@@ -125,4 +125,21 @@ export function formatBillingType(type: string | undefined | null): string {
'free_tier': '免费套餐'
}
return typeMap[type || ''] || type || '按量付费'
}
// Format cost with 4 decimal places (for cache analysis)
export function formatCost(cost: number | null | undefined): string {
if (cost === null || cost === undefined) return '-'
return `$${cost.toFixed(4)}`
}
// Format remaining time from unix timestamp
export function formatRemainingTime(expireAt: number | undefined, currentTime: number): string {
if (!expireAt) return '未知'
const remaining = expireAt - currentTime
if (remaining <= 0) return '已过期'
const minutes = Math.floor(remaining / 60)
const seconds = Math.floor(remaining % 60)
return `${minutes}${seconds}`
}