From cce3b8fb516bec20b7576aa440f184b6dca3c004 Mon Sep 17 00:00:00 2001 From: coso Date: Sat, 20 Dec 2025 15:53:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=87=AD=E8=AF=81=E6=B1=A0=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=8C=BA=E5=88=86=20API=20Key=20=E5=92=8C=20OAuth=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - API Key 类型凭证直接使用 api_key 和 base_url,无需代理 - OAuth 类型凭证继续通过 ProxyCast 代理访问 - 更新版本号至 0.14.2 --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/components/clients/ProviderForm.tsx | 41 ++++++++++++++++++++++--- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index c6037050c..647f24b52 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "proxycast", "private": true, - "version": "0.14.1", + "version": "0.14.2", "type": "module", "repository": { "type": "git", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index cb0c72663..1ca411650 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "proxycast" -version = "0.14.1" +version = "0.14.2" dependencies = [ "anyhow", "async-stream", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 27592d4c4..f927f4e65 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proxycast" -version = "0.14.1" +version = "0.14.2" description = "AI API Proxy Desktop App" authors = ["you"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f136f095f..e40d75a5a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ProxyCast", - "version": "0.14.1", + "version": "0.14.2", "identifier": "com.proxycast.app", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/components/clients/ProviderForm.tsx b/src/components/clients/ProviderForm.tsx index 1243df53a..ed67f76a4 100644 --- a/src/components/clients/ProviderForm.tsx +++ b/src/components/clients/ProviderForm.tsx @@ -640,10 +640,43 @@ export function ProviderForm({ const handleCredentialSelect = async (credential: CredentialDisplay) => { setSelectedCredentialUuid(credential.uuid); setName(credential.name || `${credential.provider_type} 凭证`); - setIconColor("#22c55e"); - // 根据凭证类型和 appType 设置配置 - // 使用 ProxyCast 代理,凭证池中的凭证通过本地代理访问 + // 判断是否为 API Key 类型凭证(非 OAuth) + const isApiKeyType = !credential.credential_type.includes("oauth"); + + // API Key 类型凭证:直接使用凭证中的 api_key 和 base_url + if (isApiKeyType && credential.api_key) { + setIconColor("#22c55e"); + + if (appType === "claude") { + setApiKey(credential.api_key); + setBaseUrl(credential.base_url || ""); + setJsonManuallyEdited(false); + } else if (appType === "codex") { + setCodexAuth( + JSON.stringify( + { + api_key: credential.api_key, + api_base_url: credential.base_url || "", + }, + null, + 2, + ), + ); + } else if (appType === "gemini") { + setGeminiEnv( + `GEMINI_API_KEY=${credential.api_key}\nGOOGLE_GEMINI_BASE_URL=${credential.base_url || ""}\nGEMINI_MODEL=gemini-2.0-flash`, + ); + } + + setNotes( + `API Key 凭证: ${credential.provider_type} - ${credential.uuid.slice(0, 8)}`, + ); + return; + } + + // OAuth 类型凭证:使用 ProxyCast 代理 + setIconColor("#3b82f6"); try { const config = await getConfig(); const proxyApiKey = config.server.api_key || ""; @@ -673,7 +706,7 @@ export function ProviderForm({ } setNotes( - `使用凭证池: ${credential.provider_type} - ${credential.uuid.slice(0, 8)}`, + `代理凭证: ${credential.provider_type} - ${credential.uuid.slice(0, 8)}`, ); } catch (e) { console.error("Failed to load config:", e);