feat(gemini): 优化 OAuth 和配额展示

主要改进:
- 修复 google_one OAuth scopes 配置问题
- 添加 Gemini 账号配额展示组件
- 优化 Code Assist 类型检测逻辑
- 添加 OAuth 测试用例
This commit is contained in:
ianshaw
2026-01-03 06:32:04 -08:00
parent 26438f7232
commit 26106eb0ac
11 changed files with 363 additions and 109 deletions

View File

@@ -12,6 +12,8 @@ export interface GeminiTokenInfo {
expires_at?: number | string
project_id?: string
oauth_type?: string
tier_id?: string
extra?: Record<string, unknown>
[key: string]: unknown
}
@@ -122,10 +124,16 @@ export function useGeminiOAuth() {
expires_at: expiresAt,
scope: tokenInfo.scope,
project_id: tokenInfo.project_id,
oauth_type: tokenInfo.oauth_type
oauth_type: tokenInfo.oauth_type,
tier_id: tokenInfo.tier_id
}
}
const buildExtraInfo = (tokenInfo: GeminiTokenInfo): Record<string, unknown> | undefined => {
if (!tokenInfo.extra || typeof tokenInfo.extra !== 'object') return undefined
return tokenInfo.extra
}
const getCapabilities = async (): Promise<GeminiOAuthCapabilities | null> => {
try {
return await adminAPI.gemini.getCapabilities()
@@ -145,6 +153,7 @@ export function useGeminiOAuth() {
generateAuthUrl,
exchangeAuthCode,
buildCredentials,
buildExtraInfo,
getCapabilities
}
}