From 7cd8f3b6c35aa2febfe258893e4364902a1909e8 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:13:18 +0800 Subject: [PATCH] fix: change error handling in patch_profiles_config to return false when a switch is in progress fix: ensure CURRENT_SWITCHING_PROFILE is reset after config updates in perform_config_update and patch_profiles_config --- src-tauri/src/cmd/profile.rs | 4 ++-- src/locales/en.json | 4 +--- src/locales/zh.json | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/cmd/profile.rs b/src-tauri/src/cmd/profile.rs index d35d9e30..4af307cb 100644 --- a/src-tauri/src/cmd/profile.rs +++ b/src-tauri/src/cmd/profile.rs @@ -388,7 +388,7 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult { .is_err() { logging!(info, Type::Cmd, "当前正在切换配置,放弃请求"); - return Err("Profile switching is already in progress".into()); + return Ok(false); } let target_profile = profiles.current.as_ref(); @@ -410,7 +410,7 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult { && validate_new_profile(switch_to_profile).await.is_err() { CURRENT_SWITCHING_PROFILE.store(false, Ordering::Release); - return Err("Target profile validation failed".into()); + return Ok(false); } let _ = Config::profiles() .await diff --git a/src/locales/en.json b/src/locales/en.json index e58962fc..2716d316 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -714,7 +714,5 @@ "Unlock menu order": "Unlock menu order", "Lock menu order": "Lock menu order", "Open App Log": "Open App Log", - "Open Core Log": "Open Core Log", - "Profile switching is already in progress": "Profile switching is already in progress", - "Target profile validation failed": "Target profile validation failed" + "Open Core Log": "Open Core Log" } diff --git a/src/locales/zh.json b/src/locales/zh.json index f927744f..f8b161d7 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -715,7 +715,5 @@ "Lock menu order": "锁定菜单排序", "Open App Log": "应用日志", "Open Core Log": "内核日志", - "TPROXY Port": "TPROXY 透明代理端口", - "Profile switching is already in progress": "配置文件切换已在进行中", - "Target profile validation failed": "目标配置文件验证失败" + "TPROXY Port": "TPROXY 透明代理端口" }