From 593f8d7ecc7b361b6f4836cc51315ed94aa4e13e Mon Sep 17 00:00:00 2001 From: coso Date: Sun, 28 Dec 2025 00:05:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98=20(Fixes=20#47)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复字符串切片可能在 UTF-8 边界 panic 的问题 - 修复 machine_id 切片可能越界的问题 - 添加更详细的日志记录以便调试 - 版本更新至 0.20.4 --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/commands/provider_pool_cmd.rs | 59 ++++++++++++++++++--- src-tauri/tauri.conf.json | 2 +- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index b08caafcb..e62d0aee0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "proxycast", "private": true, - "version": "0.20.3", + "version": "0.20.4", "type": "module", "repository": { "type": "git", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index b63bf0de7..9a0fe5ae2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "proxycast" -version = "0.20.3" +version = "0.20.4" dependencies = [ "anyhow", "arboard", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 57ccca58c..13ab9a743 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proxycast" -version = "0.20.3" +version = "0.20.4" description = "AI API Proxy Desktop App" authors = ["you"] edition = "2021" diff --git a/src-tauri/src/commands/provider_pool_cmd.rs b/src-tauri/src/commands/provider_pool_cmd.rs index 2e6afd034..f5f3a8ab5 100644 --- a/src-tauri/src/commands/provider_pool_cmd.rs +++ b/src-tauri/src/commands/provider_pool_cmd.rs @@ -612,10 +612,21 @@ pub fn add_kiro_oauth_credential( creds_file_path: String, name: Option, ) -> Result { - // 复制并重命名文件到应用存储目录 - let stored_file_path = copy_and_rename_credential_file(&creds_file_path, "kiro")?; + tracing::info!("[KIRO] 开始添加凭证,文件路径: {}", creds_file_path); - pool_service.0.add_credential( + // 复制并重命名文件到应用存储目录 + let stored_file_path = match copy_and_rename_credential_file(&creds_file_path, "kiro") { + Ok(path) => { + tracing::info!("[KIRO] 凭证文件已复制到: {}", path); + path + } + Err(e) => { + tracing::error!("[KIRO] 复制凭证文件失败: {}", e); + return Err(e); + } + }; + + match pool_service.0.add_credential( &db, "kiro", CredentialData::KiroOAuth { @@ -624,7 +635,16 @@ pub fn add_kiro_oauth_credential( name, Some(true), None, - ) + ) { + Ok(cred) => { + tracing::info!("[KIRO] 凭证添加成功,UUID: {}", cred.uuid); + Ok(cred) + } + Err(e) => { + tracing::error!("[KIRO] 添加凭证到数据库失败: {}", e); + Err(e) + } + } } /// 从 JSON 内容创建 Kiro 凭证文件并添加到凭证池 @@ -789,10 +809,24 @@ pub fn add_kiro_from_json( json_content: String, name: Option, ) -> Result { - // 从 JSON 内容创建凭证文件 - let stored_file_path = create_kiro_credential_from_json(&json_content)?; + tracing::info!( + "[KIRO] 开始从 JSON 添加凭证,内容长度: {}", + json_content.len() + ); - pool_service.0.add_credential( + // 从 JSON 内容创建凭证文件 + let stored_file_path = match create_kiro_credential_from_json(&json_content) { + Ok(path) => { + tracing::info!("[KIRO] 凭证文件已创建: {}", path); + path + } + Err(e) => { + tracing::error!("[KIRO] 创建凭证文件失败: {}", e); + return Err(e); + } + }; + + match pool_service.0.add_credential( &db, "kiro", CredentialData::KiroOAuth { @@ -801,7 +835,16 @@ pub fn add_kiro_from_json( name, Some(true), None, - ) + ) { + Ok(cred) => { + tracing::info!("[KIRO] 凭证添加成功,UUID: {}", cred.uuid); + Ok(cred) + } + Err(e) => { + tracing::error!("[KIRO] 添加凭证到数据库失败: {}", e); + Err(e) + } + } } /// 添加 Gemini OAuth 凭证(通过文件路径) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 442faae32..95616ff0a 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.20.3", + "version": "0.20.4", "identifier": "com.proxycast.app", "build": { "beforeDevCommand": "npm run dev",