diff --git a/.gitignore b/.gitignore index 9b8304016..7268b6233 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ scripts/_env.sh target CLAUDE.md .vfox.toml +.vfox/ diff --git a/src-tauri/src/cmd/profile.rs b/src-tauri/src/cmd/profile.rs index a2bc99b04..d23e90ce2 100644 --- a/src-tauri/src/cmd/profile.rs +++ b/src-tauri/src/cmd/profile.rs @@ -173,6 +173,13 @@ pub async fn delete_profile(index: String) -> CmdResult { // 使用Send-safe helper函数 let should_update = profiles_delete_item_safe(&index).await.stringify_err()?; profiles_save_file_safe().await.stringify_err()?; + if let Err(e) = Tray::global().update_tooltip().await { + logging!(warn, Type::Cmd, "Warning: 异步更新托盘提示失败: {e}"); + } + + if let Err(e) = Tray::global().update_menu().await { + logging!(warn, Type::Cmd, "Warning: 异步更新托盘菜单失败: {e}"); + } if should_update { Config::profiles().await.apply(); match CoreManager::global().update_config().await { diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index 21c5b22e8..9592cf848 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -263,16 +263,20 @@ impl IProfiles { pub async fn delete_item(&mut self, uid: &String) -> Result { let current = self.current.as_ref().unwrap_or(uid); let current = current.clone(); - let (merge_uid, script_uid, rules_uid, proxies_uid, groups_uid) = { + let delete_uids = { let item = self.get_item(uid)?; let option = item.option.as_ref(); - ( - option.and_then(|e| e.merge.clone()), - option.and_then(|e| e.script.clone()), - option.and_then(|e| e.rules.clone()), - option.and_then(|e| e.proxies.clone()), - option.and_then(|e| e.groups.clone()), - ) + option.map_or(Vec::new(), |op| { + [ + op.merge.clone(), + op.script.clone(), + op.rules.clone(), + op.proxies.clone(), + op.groups.clone(), + ] + .into_iter() + .collect::>() + }) }; let mut items = self.items.take().unwrap_or_default(); @@ -281,22 +285,12 @@ impl IProfiles { let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; } - // remove related extension items (merge, script, rules, proxies, groups) - if let Some(file) = Self::take_item_file_by_uid(&mut items, merge_uid.as_deref()) { - let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; - } - if let Some(file) = Self::take_item_file_by_uid(&mut items, script_uid.as_deref()) { - let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; - } - if let Some(file) = Self::take_item_file_by_uid(&mut items, rules_uid.as_deref()) { - let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; - } - if let Some(file) = Self::take_item_file_by_uid(&mut items, proxies_uid.as_deref()) { - let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; - } - if let Some(file) = Self::take_item_file_by_uid(&mut items, groups_uid.as_deref()) { - let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; + for delete_uid in delete_uids { + if let Some(file) = Self::take_item_file_by_uid(&mut items, delete_uid.as_deref()) { + let _ = dirs::app_profiles_dir()?.join(file.as_str()).remove_if_exists().await; + } } + // delete the original uid if current == *uid { self.current = None;