mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
feat(frontend): centralize client family labels
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
} from '@/composables/useTTLAnalysis'
|
||||
import { log } from '@/utils/logger'
|
||||
import { formatApiFormat } from '@/api/endpoints/types/api-format'
|
||||
import { formatClientFamily } from '@/features/usage/utils/clientFamily'
|
||||
|
||||
// ==================== 缓存统计与亲和性列表 ====================
|
||||
|
||||
@@ -264,27 +265,6 @@ function affinityModelSubtitle(item: UserAffinity): string {
|
||||
return item.model_name
|
||||
}
|
||||
|
||||
function formatClientFamily(family?: string | null): string {
|
||||
switch (family) {
|
||||
case 'codex':
|
||||
return 'Codex'
|
||||
case 'opencode':
|
||||
return 'OpenCode'
|
||||
case 'claude_code':
|
||||
return 'Claude Code'
|
||||
case 'openai_js_sdk':
|
||||
return 'OpenAI JS SDK'
|
||||
case 'generic':
|
||||
return '通用'
|
||||
case undefined:
|
||||
case null:
|
||||
case '':
|
||||
return '未知'
|
||||
default:
|
||||
return family
|
||||
}
|
||||
}
|
||||
|
||||
function providerKeyLabel(item: UserAffinity): string {
|
||||
if (item.key_name) return item.key_name
|
||||
if (item.key_prefix === '[OAuth Token]') return 'OAuth 认证'
|
||||
|
||||
@@ -547,6 +547,15 @@ async function pollActiveRequests() {
|
||||
? update.provider_key_name
|
||||
: undefined
|
||||
}
|
||||
if ('client_family' in update) {
|
||||
record.client_family = typeof update.client_family === 'string' ? update.client_family : null
|
||||
}
|
||||
if ('client_ip' in update) {
|
||||
record.client_ip = typeof update.client_ip === 'string' ? update.client_ip : null
|
||||
}
|
||||
if ('user_agent' in update) {
|
||||
record.user_agent = typeof update.user_agent === 'string' ? update.user_agent : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user