feat: 凭证池导入区分 API Key 和 OAuth 类型

- API Key 类型凭证直接使用 api_key 和 base_url,无需代理
- OAuth 类型凭证继续通过 ProxyCast 代理访问
- 更新版本号至 0.14.2
This commit is contained in:
coso
2025-12-20 15:53:13 +08:00
parent bc10b355a7
commit cce3b8fb51
5 changed files with 41 additions and 8 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "proxycast",
"private": true,
"version": "0.14.1",
"version": "0.14.2",
"type": "module",
"repository": {
"type": "git",
+1 -1
View File
@@ -3367,7 +3367,7 @@ dependencies = [
[[package]]
name = "proxycast"
version = "0.14.1"
version = "0.14.2"
dependencies = [
"anyhow",
"async-stream",
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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",
+37 -4
View File
@@ -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);