feat(pool,priority): 号池聚合显示、API 格式归一化与优先级管理重构

- 优先级管理对话框按 family 分组显示 API 格式,号池 key 聚合为单条目展示
- 拖拽排序改用 key ID 替代数组索引,号池聚合项禁用拖拽/编辑/开关操作
- 后端 key 分组查询增加 API 格式键归一化,返回 provider_id
- 提取 OAuth auth_config 解密逻辑,新增 _derive_oauth_expires_at 从加密配置派生过期时间
- 号池管理移除会话列,调整 OAuth 过期信息与刷新按钮的布局顺序
This commit is contained in:
fawney19
2026-03-04 12:59:27 +08:00
parent 095e312ab3
commit 57b86034cf
6 changed files with 694 additions and 143 deletions

View File

@@ -73,6 +73,62 @@ export const API_FORMAT_ORDER: string[] = [
API_FORMATS.GEMINI_VIDEO,
]
// Family 显示名称映射
export const API_FORMAT_FAMILY_LABELS: Record<string, string> = {
openai: 'OpenAI',
claude: 'Claude',
gemini: 'Gemini',
}
// Kind 显示名称映射
export const API_FORMAT_KIND_LABELS: Record<string, string> = {
chat: 'Chat',
cli: 'CLI',
compact: 'Compact',
video: 'Video',
}
// Family 排序顺序
const FAMILY_ORDER = ['openai', 'claude', 'gemini']
// 工具函数:从 API 格式中提取 family 和 kind
export function parseApiFormat(format: string): { family: string; kind: string } {
const idx = format.indexOf(':')
if (idx === -1) return { family: format.toLowerCase(), kind: '' }
return { family: format.slice(0, idx).toLowerCase(), kind: format.slice(idx + 1).toLowerCase() }
}
// 工具函数:按 family 分组并排序 API 格式数组
export interface ApiFormatGroup {
family: string
label: string
formats: string[]
}
export function groupApiFormats(formats: string[]): ApiFormatGroup[] {
const sorted = sortApiFormats(formats)
const groups = new Map<string, string[]>()
for (const f of sorted) {
const { family } = parseApiFormat(f)
if (!groups.has(family)) groups.set(family, [])
groups.get(family)?.push(f)
}
return [...groups.entries()]
.sort(([a], [b]) => {
const ai = FAMILY_ORDER.indexOf(a)
const bi = FAMILY_ORDER.indexOf(b)
if (ai === -1 && bi === -1) return 0
if (ai === -1) return 1
if (bi === -1) return -1
return ai - bi
})
.map(([family, fmts]) => ({
family,
label: API_FORMAT_FAMILY_LABELS[family] || family,
formats: fmts,
}))
}
// 工具函数:将 API 格式签名转为友好显示名称
export function formatApiFormat(format: string | null | undefined): string {
if (!format) return '-'