feat(frontend): 新增 Gemini OAuth 授权流程

- 新增 /admin/gemini API 接口封装(generateAuthUrl, exchangeCode)
- 新增 useGeminiOAuth composable 处理 Gemini OAuth 流程
- 新增 OAuthCallbackView 视图用于接收 OAuth 回调
- 支持 code/state 参数提取和 credentials 构建
This commit is contained in:
ianshaw
2025-12-25 08:39:48 -08:00
parent 03a8ae62e5
commit 0b30cc2b7e
3 changed files with 267 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
/**
* Admin Gemini API endpoints
* Handles Gemini OAuth flows for administrators
*/
import { apiClient } from '../client'
export interface GeminiAuthUrlResponse {
auth_url: string
session_id: string
state: string
}
export interface GeminiAuthUrlRequest {
redirect_uri: string
proxy_id?: number
}
export interface GeminiExchangeCodeRequest {
session_id: string
state: string
code: string
redirect_uri: string
proxy_id?: number
}
export type GeminiTokenInfo = Record<string, unknown>
export async function generateAuthUrl(
payload: GeminiAuthUrlRequest
): Promise<GeminiAuthUrlResponse> {
const { data } = await apiClient.post<GeminiAuthUrlResponse>(
'/admin/gemini/oauth/auth-url',
payload
)
return data
}
export async function exchangeCode(payload: GeminiExchangeCodeRequest): Promise<GeminiTokenInfo> {
const { data } = await apiClient.post<GeminiTokenInfo>(
'/admin/gemini/oauth/exchange-code',
payload
)
return data
}
export default { generateAuthUrl, exchangeCode }