mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
feat: 增强 OAuth 标识展示与 Codex 调试日志
- 优化 OAuth badge 支持 account_id/account_user_id,tooltip 展示完整身份信息 - 重构池管理额度进度条布局,倒计时独立展示并增加样式区分 - Codex 插件增加 token 解析快照日志,便于排查 OAuth 透传问题 Closes #245 Co-Authored-By: kayphoon <109347466+Kayphoon@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import type { OAuthOrganizationInfo } from '@/api/endpoints/types/provider'
|
||||
|
||||
type OAuthIdentityDisplayValue = {
|
||||
oauth_account_id?: string | null
|
||||
oauth_account_name?: string | null
|
||||
oauth_account_user_id?: string | null
|
||||
oauth_organizations?: OAuthOrganizationInfo[] | null
|
||||
} | null | undefined
|
||||
|
||||
@@ -16,6 +18,14 @@ function formatOAuthIdentityShort(
|
||||
return `${normalized.slice(0, head)}...${normalized.slice(-tail)}`
|
||||
}
|
||||
|
||||
function readStr(raw: unknown): string {
|
||||
return typeof raw === 'string' ? raw.trim() : ''
|
||||
}
|
||||
|
||||
function formatOAuthAccountBadge(accountId: string): string {
|
||||
return accountId.slice(0, 8)
|
||||
}
|
||||
|
||||
function getPrimaryOAuthOrganization(
|
||||
value: OAuthIdentityDisplayValue,
|
||||
): { id: string; title: string } | null {
|
||||
@@ -44,16 +54,30 @@ function getPrimaryOAuthOrganization(
|
||||
|
||||
export function getOAuthOrgBadge(
|
||||
value: OAuthIdentityDisplayValue,
|
||||
): { id: string; label: string } | null {
|
||||
): { id: string; label: string; title: string } | null {
|
||||
const org = getPrimaryOAuthOrganization(value)
|
||||
if (!org) return null
|
||||
|
||||
const accountName = typeof value?.oauth_account_name === 'string'
|
||||
? value.oauth_account_name.trim()
|
||||
: ''
|
||||
const accountId = readStr(value?.oauth_account_id)
|
||||
const accountName = readStr(value?.oauth_account_name)
|
||||
const accountUserId = readStr(value?.oauth_account_user_id)
|
||||
|
||||
const badgeId = accountId || org?.id || ''
|
||||
const label = accountName
|
||||
|| (accountId ? formatOAuthAccountBadge(accountId) : '')
|
||||
|| (org?.id ? `org:${formatOAuthIdentityShort(org.id, 6, 4)}` : '')
|
||||
if (!badgeId || !label) return null
|
||||
|
||||
const titleParts = [
|
||||
accountName ? `name: ${accountName}` : '',
|
||||
accountId ? `account_id: ${accountId}` : '',
|
||||
accountUserId ? `account_user_id: ${accountUserId}` : '',
|
||||
org?.id ? `org_id: ${org.id}` : '',
|
||||
org?.title ? `org_title: ${org.title}` : '',
|
||||
].filter(Boolean)
|
||||
|
||||
return {
|
||||
id: org.id,
|
||||
label: accountName || org.title || formatOAuthIdentityShort(org.id),
|
||||
id: badgeId,
|
||||
label,
|
||||
title: titleParts.join(' | '),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user