mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-31 02:51:21 +08:00
* fix: Claude Desktop 官方供应商添加时缺少 ANTHROPIC_BASE_URL 报错 根因:前端 mutation 为 claude-desktop 生成随机 UUID 作为 provider id, 后端 is_official_provider 通过 id 匹配跳过校验,随机 UUID 不匹配导致 走入普通 direct 模式校验并要求 ANTHROPIC_BASE_URL。 修复: - 前端:claude-desktop + category=official 时使用固定 id "claude-desktop-official" - 后端:validate_provider / validate_direct_provider / validate_proxy_provider / apply_provider_to_paths 增加 category=="official" 兜底检查 Fixes #3402 * fix: restrict Claude Desktop official provider detection * fix: add Claude Desktop official provider via seed --------- Co-authored-by: 金恩光 <enguang.jin@gmail.com> Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -1947,12 +1947,13 @@ mod tests {
|
||||
let direct = direct_provider("direct");
|
||||
assert!(is_compatible_direct_provider(&direct));
|
||||
|
||||
let claude_official = Provider::with_id(
|
||||
let mut claude_official = Provider::with_id(
|
||||
"claude-official".to_string(),
|
||||
"Claude Official".to_string(),
|
||||
json!({"env": {}}),
|
||||
Some("https://www.anthropic.com/claude-code".to_string()),
|
||||
);
|
||||
claude_official.category = Some("official".to_string());
|
||||
assert!(!is_compatible_direct_provider(&claude_official));
|
||||
|
||||
let mut openai_format = direct_provider("openai");
|
||||
|
||||
@@ -219,6 +219,17 @@ pub fn import_claude_desktop_providers_from_claude(
|
||||
Ok(imported)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ensure_claude_desktop_official_provider(state: State<'_, AppState>) -> Result<bool, String> {
|
||||
state
|
||||
.db
|
||||
.ensure_official_seed_by_id(
|
||||
crate::database::CLAUDE_DESKTOP_OFFICIAL_PROVIDER_ID,
|
||||
AppType::ClaudeDesktop,
|
||||
)
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn claude_provider_models_are_claude_safe(provider: &Provider) -> bool {
|
||||
let Some(env) = provider
|
||||
.settings_config
|
||||
|
||||
@@ -1105,6 +1105,7 @@ pub fn run() {
|
||||
commands::get_claude_desktop_status,
|
||||
commands::get_claude_desktop_default_routes,
|
||||
commands::import_claude_desktop_providers_from_claude,
|
||||
commands::ensure_claude_desktop_official_provider,
|
||||
commands::get_claude_config_status,
|
||||
commands::get_config_status,
|
||||
commands::get_claude_code_config_path,
|
||||
|
||||
Reference in New Issue
Block a user