mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
feat(pool): 增加 OAuth 账号池管理功能
- 新增 pool manager / strategy / health_policy / cost_tracker / redis_ops 等核心模块 - 新增 pool admin API 路由与 schemas - 新增 OAuth 账号类型解析 (oauth_plan) - 前端增加 PoolManagement 页面、PoolConfigDialog、PoolImportDialog、PoolStatusCard 组件 - 补充 pool config / cost tracker / health policy / manager / strategy / trace 等测试
This commit is contained in:
70
frontend/src/utils/oauthPlanType.ts
Normal file
70
frontend/src/utils/oauthPlanType.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
const PLAN_TYPE_LABELS: Record<string, string> = {
|
||||
free: 'Free',
|
||||
plus: 'Plus',
|
||||
team: 'Team',
|
||||
enterprise: 'Enterprise',
|
||||
paid: 'Paid',
|
||||
pro: 'Pro',
|
||||
'pro+': 'Pro+',
|
||||
power: 'Power',
|
||||
ultra: 'Ultra',
|
||||
}
|
||||
|
||||
const PLAN_TYPE_CLASS_NAMES: Record<string, string> = {
|
||||
plus: 'border-green-500/50 text-green-600 dark:text-green-400',
|
||||
pro: 'border-blue-500/50 text-blue-600 dark:text-blue-400',
|
||||
free: 'border-primary/50 text-primary',
|
||||
paid: 'border-blue-500/50 text-blue-600 dark:text-blue-400',
|
||||
team: 'border-purple-500/50 text-purple-600 dark:text-purple-400',
|
||||
enterprise: 'border-amber-500/50 text-amber-600 dark:text-amber-400',
|
||||
ultra: 'border-amber-500/50 text-amber-600 dark:text-amber-400',
|
||||
'pro+': 'border-purple-500/50 text-purple-600 dark:text-purple-400',
|
||||
power: 'border-amber-500/50 text-amber-600 dark:text-amber-400',
|
||||
}
|
||||
|
||||
export function normalizeOAuthPlanType(planType?: string | null): string | null {
|
||||
if (typeof planType !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
const normalized = planType.trim().toLowerCase()
|
||||
if (!normalized) {
|
||||
return null
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
export function formatOAuthPlanType(planType?: string | null): string {
|
||||
const normalized = normalizeOAuthPlanType(planType)
|
||||
if (!normalized) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const knownLabel = PLAN_TYPE_LABELS[normalized]
|
||||
if (knownLabel) {
|
||||
return knownLabel
|
||||
}
|
||||
|
||||
return normalized
|
||||
.replace(/[_-]+/g, ' ')
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.map(part => part[0].toUpperCase() + part.slice(1))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
export function getOAuthPlanTypeClass(planType?: string | null): string {
|
||||
const normalized = normalizeOAuthPlanType(planType)
|
||||
if (!normalized) {
|
||||
return ''
|
||||
}
|
||||
return PLAN_TYPE_CLASS_NAMES[normalized] || ''
|
||||
}
|
||||
|
||||
export function isNonFreeOAuthPlan(planType?: string | null): boolean {
|
||||
const normalized = normalizeOAuthPlanType(planType)
|
||||
if (!normalized) {
|
||||
return false
|
||||
}
|
||||
return normalized !== 'free'
|
||||
}
|
||||
Reference in New Issue
Block a user