mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-03-30 03:26:10 +00:00
- 打通 service_tier 在 OpenAI HTTP、WS、passthrough 与 usage 记录中的传递 - 修正 priority/flex 计费逻辑,并将 fast 归一化为 priority - 在用户端和管理端补齐服务档位与计费明细展示 - 补齐前后端测试,并修复 WS 限流信号重复持久化导致的全量回归失败 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
964 B
TypeScript
26 lines
964 B
TypeScript
export function normalizeUsageServiceTier(serviceTier?: string | null): string | null {
|
|
const value = serviceTier?.trim().toLowerCase()
|
|
if (!value) return null
|
|
if (value === 'fast') return 'priority'
|
|
if (value === 'default' || value === 'standard') return 'standard'
|
|
if (value === 'priority' || value === 'flex') return value
|
|
return value
|
|
}
|
|
|
|
export function formatUsageServiceTier(serviceTier?: string | null): string {
|
|
const normalized = normalizeUsageServiceTier(serviceTier)
|
|
if (!normalized) return 'standard'
|
|
return normalized
|
|
}
|
|
|
|
export function getUsageServiceTierLabel(
|
|
serviceTier: string | null | undefined,
|
|
translate: (key: string) => string,
|
|
): string {
|
|
const tier = formatUsageServiceTier(serviceTier)
|
|
if (tier === 'priority') return translate('usage.serviceTierPriority')
|
|
if (tier === 'flex') return translate('usage.serviceTierFlex')
|
|
if (tier === 'standard') return translate('usage.serviceTierStandard')
|
|
return tier
|
|
}
|