Skip to content

Commit c1b1f87

Browse files
committed
feat: 端点 Provider 配置 + 凭证卡片 UI 优化
- 实现客户端路由功能,根据 User-Agent 自动选择 Provider - 新增客户端路由 tab 在路由管理页面 - 推荐配置支持客户端路由 - 优化凭证卡片布局,使用网格布局显示统计信息 - Token 有效期移到卡片主体显示 - 展开区域使用彩色背景卡片
1 parent 44f7c20 commit c1b1f87

21 files changed

Lines changed: 1782 additions & 154 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "proxycast",
33
"private": true,
4-
"version": "0.17.1",
4+
"version": "0.17.2",
55
"type": "module",
66
"repository": {
77
"type": "git",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "proxycast"
3-
version = "0.17.1"
3+
version = "0.17.2"
44
description = "AI API Proxy Desktop App"
55
authors = ["you"]
66
edition = "2021"

src-tauri/src/commands/router_cmd.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,26 @@ pub struct RecommendedPreset {
186186
pub description: String,
187187
pub aliases: Vec<ModelAlias>,
188188
pub rules: Vec<RoutingRuleDto>,
189+
/// 客户端路由配置
190+
#[serde(default, skip_serializing_if = "Option::is_none")]
191+
pub endpoint_providers: Option<EndpointProvidersConfigDto>,
192+
}
193+
194+
/// 端点 Provider 配置 DTO
195+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
196+
pub struct EndpointProvidersConfigDto {
197+
#[serde(default, skip_serializing_if = "Option::is_none")]
198+
pub cursor: Option<String>,
199+
#[serde(default, skip_serializing_if = "Option::is_none")]
200+
pub claude_code: Option<String>,
201+
#[serde(default, skip_serializing_if = "Option::is_none")]
202+
pub codex: Option<String>,
203+
#[serde(default, skip_serializing_if = "Option::is_none")]
204+
pub windsurf: Option<String>,
205+
#[serde(default, skip_serializing_if = "Option::is_none")]
206+
pub kiro: Option<String>,
207+
#[serde(default, skip_serializing_if = "Option::is_none")]
208+
pub other: Option<String>,
189209
}
190210

191211
/// 获取推荐配置列表
@@ -260,6 +280,7 @@ pub async fn get_recommended_presets() -> Result<Vec<RecommendedPreset>, String>
260280
enabled: true,
261281
},
262282
],
283+
endpoint_providers: None,
263284
},
264285
RecommendedPreset {
265286
id: "gemini-optimized".to_string(),
@@ -308,6 +329,7 @@ pub async fn get_recommended_presets() -> Result<Vec<RecommendedPreset>, String>
308329
enabled: true,
309330
},
310331
],
332+
endpoint_providers: None,
311333
},
312334
RecommendedPreset {
313335
id: "multi-provider".to_string(),
@@ -398,6 +420,7 @@ pub async fn get_recommended_presets() -> Result<Vec<RecommendedPreset>, String>
398420
enabled: true,
399421
},
400422
],
423+
endpoint_providers: None,
401424
},
402425
RecommendedPreset {
403426
id: "coding-assistant".to_string(),
@@ -443,6 +466,7 @@ pub async fn get_recommended_presets() -> Result<Vec<RecommendedPreset>, String>
443466
enabled: true,
444467
},
445468
],
469+
endpoint_providers: None,
446470
},
447471
RecommendedPreset {
448472
id: "cost-effective".to_string(),
@@ -478,6 +502,24 @@ pub async fn get_recommended_presets() -> Result<Vec<RecommendedPreset>, String>
478502
enabled: true,
479503
},
480504
],
505+
endpoint_providers: None,
506+
},
507+
// 客户端路由预设
508+
RecommendedPreset {
509+
id: "client-routing".to_string(),
510+
name: "客户端路由配置".to_string(),
511+
description: "为不同的 IDE 客户端配置不同的 Provider,Cursor/Windsurf 使用 Kiro,Claude Code 使用 Kiro,Codex 使用 OpenAI"
512+
.to_string(),
513+
aliases: vec![],
514+
rules: vec![],
515+
endpoint_providers: Some(EndpointProvidersConfigDto {
516+
cursor: Some("kiro".to_string()),
517+
claude_code: Some("kiro".to_string()),
518+
codex: Some("openai".to_string()),
519+
windsurf: Some("kiro".to_string()),
520+
kiro: Some("kiro".to_string()),
521+
other: None,
522+
}),
481523
},
482524
])
483525
}

src-tauri/src/config/hot_reload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! - 支持原子性配置更新
66
//! - 失败时自动回滚到之前的配置
77
8-
use super::types::Config;
8+
use super::types::{is_default_api_key, Config};
99
use super::yaml::ConfigManager;
1010
use notify::{Event, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
1111
use parking_lot::RwLock;
@@ -414,7 +414,7 @@ impl HotReloadManager {
414414
}
415415

416416
if (!is_localhost || config.remote_management.allow_remote)
417-
&& crate::config::is_default_api_key(&config.server.api_key)
417+
&& is_default_api_key(&config.server.api_key)
418418
{
419419
return Err(HotReloadError::ValidationError(
420420
"非本地访问场景下禁止使用默认 API Key,请设置强口令".to_string(),

src-tauri/src/config/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ pub use hot_reload::{
1717
pub use import::{ImportOptions, ImportService, ValidationResult};
1818
pub use path_utils::{collapse_tilde, contains_tilde, expand_tilde};
1919
pub use types::{
20-
AmpConfig, AmpModelMapping, ApiKeyEntry, Config, CredentialEntry, CredentialPoolConfig,
21-
CustomProviderConfig, GeminiApiKeyEntry, IFlowCredentialEntry, InjectionRuleConfig,
22-
InjectionSettings, LoggingConfig, ProviderConfig, ProvidersConfig, QuotaExceededConfig,
23-
RemoteManagementConfig, RetrySettings, RoutingConfig, ServerConfig, TlsConfig,
24-
VertexApiKeyEntry, VertexModelAlias,
20+
generate_secure_api_key, AmpConfig, AmpModelMapping, ApiKeyEntry, Config, CredentialEntry,
21+
CredentialPoolConfig, CustomProviderConfig, EndpointProvidersConfig, GeminiApiKeyEntry,
22+
IFlowCredentialEntry, InjectionRuleConfig, InjectionSettings, LoggingConfig, ProviderConfig,
23+
ProvidersConfig, QuotaExceededConfig, RemoteManagementConfig, RetrySettings, RoutingConfig,
24+
ServerConfig, TlsConfig, VertexApiKeyEntry, VertexModelAlias, DEFAULT_API_KEY,
2525
};
2626
pub use yaml::{load_config, save_config, ConfigError, ConfigManager, YamlService};
2727

0 commit comments

Comments
 (0)