mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
feat: 添加账号时支持同步上游模型
新增 POST /admin/accounts/models/sync-upstream-preview 端点, 允许在创建账号流程中直接使用凭证同步上游支持的模型, 无需先保存账号获取 ID。 - 后端: 新增 SyncUpstreamModelsPreview handler - 前端: 新增 syncUpstreamModelsPreview API 函数 - 前端: ModelWhitelistSelector 支持 syncCredentials prop - 前端: CreateAccountModal 传递凭证给 ModelWhitelistSelector
This commit is contained in:
@@ -487,6 +487,23 @@ export async function syncUpstreamModels(id: number): Promise<SyncUpstreamModels
|
||||
return data
|
||||
}
|
||||
|
||||
export interface SyncUpstreamPreviewParams {
|
||||
platform: string
|
||||
type: string
|
||||
base_url?: string
|
||||
api_key: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview upstream models without a saved account (create-flow)
|
||||
* @param params - Connection credentials
|
||||
* @returns List of model IDs returned by the upstream
|
||||
*/
|
||||
export async function syncUpstreamModelsPreview(params: SyncUpstreamPreviewParams): Promise<SyncUpstreamModelsResult> {
|
||||
const { data } = await apiClient.post<SyncUpstreamModelsResult>('/admin/accounts/models/sync-upstream-preview', params)
|
||||
return data
|
||||
}
|
||||
|
||||
export interface CRSPreviewAccount {
|
||||
crs_account_id: string
|
||||
kind: string
|
||||
@@ -703,6 +720,7 @@ export const accountsAPI = {
|
||||
setSchedulable,
|
||||
getAvailableModels,
|
||||
syncUpstreamModels,
|
||||
syncUpstreamModelsPreview,
|
||||
generateAuthUrl,
|
||||
exchangeCode,
|
||||
refreshOpenAIToken,
|
||||
|
||||
Reference in New Issue
Block a user