From fb5bf72fb97d5494e19d6b4d69ff0e5802459fbb Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sun, 2 Nov 2025 20:07:47 +0800 Subject: [PATCH 1/2] feat: add function to retrieve profile name by UID and improve error logging for profile updates --- src-tauri/src/config/profiles.rs | 16 ++++++++++++++-- src-tauri/src/core/tray/mod.rs | 6 ++---- src-tauri/src/feat/profile.rs | 9 +++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index 98886afc..f25e5990 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -435,8 +435,8 @@ impl IProfiles { } /// 判断profile是否是current指向的 - pub fn is_current_profile_index(&self, index: String) -> bool { - self.current == Some(index) + pub fn is_current_profile_index(&self, index: &String) -> bool { + self.current.as_ref() == Some(index) } /// 获取所有的profiles(uid,名称) @@ -455,6 +455,18 @@ impl IProfiles { }) } + /// 通过 uid 获取名称 + pub fn get_name_by_uid(&self, uid: &String) -> Option { + if let Some(items) = &self.items { + for item in items { + if item.uid.as_ref() == Some(uid) { + return item.name.clone(); + } + } + } + None + } + /// 以 app 中的 profile 列表为准,删除不再需要的文件 pub async fn cleanup_orphaned_files(&self) -> Result { let profiles_dir = dirs::app_profiles_dir()?; diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index 8261c98a..474b0202 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -673,17 +673,15 @@ async fn create_profile_menu_item( .iter() .map(|(profile_uid, profile_name)| { let app_handle = app_handle.clone(); - let profile_uid = profile_uid.clone(); - let profile_name = profile_name.clone(); async move { let is_current_profile = Config::profiles() .await .latest_ref() - .is_current_profile_index(profile_uid.clone()); + .is_current_profile_index(profile_uid); CheckMenuItem::with_id( &app_handle, format!("profiles_{profile_uid}"), - t(&profile_name).await, + t(profile_name).await, true, is_current_profile, None::<&str>, diff --git a/src-tauri/src/feat/profile.rs b/src-tauri/src/feat/profile.rs index 273022a5..2bd8512c 100644 --- a/src-tauri/src/feat/profile.rs +++ b/src-tauri/src/feat/profile.rs @@ -140,14 +140,19 @@ async fn perform_profile_update( Ok(is_current) } Err(retry_err) => { + let failed_profile_name = Config::profiles() + .await + .latest_ref() + .get_name_by_uid(uid) + .unwrap_or_default(); logging!( error, Type::Config, - "[订阅更新] 使用Clash代理更新仍然失败: {retry_err}" + "[订阅更新] 使用Clash代理更新仍然失败: {failed_profile_name} - {retry_err}" ); handle::Handle::notice_message( "update_failed_even_with_clash", - format!("{retry_err}"), + format!("{failed_profile_name} - {retry_err}"), ); Err(retry_err) } From 36d1a3878fb23c8ebee128ba0765eb32b0dd93f1 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sun, 2 Nov 2025 20:13:09 +0800 Subject: [PATCH 2/2] refactor: remove retry notice for Clash proxy updates from notification handlers and localization files --- src-tauri/src/feat/profile.rs | 1 - src/locales/de.json | 1 - src/locales/en.json | 1 - src/locales/es.json | 1 - src/locales/jp.json | 1 - src/locales/ko.json | 1 - src/locales/tr.json | 1 - src/locales/zh.json | 1 - src/locales/zhtw.json | 1 - src/pages/_layout/notificationHandlers.ts | 2 -- 10 files changed, 11 deletions(-) diff --git a/src-tauri/src/feat/profile.rs b/src-tauri/src/feat/profile.rs index 2bd8512c..5cee61d2 100644 --- a/src-tauri/src/feat/profile.rs +++ b/src-tauri/src/feat/profile.rs @@ -107,7 +107,6 @@ async fn perform_profile_update( Type::Config, "Warning: [订阅更新] 正常更新失败: {err},尝试使用Clash代理更新" ); - handle::Handle::notice_message("update_retry_with_clash", uid.clone()); let original_with_proxy = merged_opt.as_ref().and_then(|o| o.with_proxy); let original_self_proxy = merged_opt.as_ref().and_then(|o| o.self_proxy); diff --git a/src/locales/de.json b/src/locales/de.json index a13b7181..2c989cfc 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -524,7 +524,6 @@ "Unknown": "Unbekannt", "Auto update disabled": "Automatische Aktualisierung deaktiviert", "Update subscription successfully": "Abonnement erfolgreich aktualisiert", - "Update failed, retrying with Clash proxy...": "Abonnement-Aktualisierung fehlgeschlagen. Versuche es mit dem Clash-Proxy erneut...", "Update with Clash proxy successfully": "Aktualisierung mit Clash-Proxy erfolgreich", "Update failed even with Clash proxy": "Aktualisierung auch mit Clash-Proxy fehlgeschlagen", "Profile creation failed, retrying with Clash proxy...": "Erstellung des Abonnements fehlgeschlagen. Versuche es mit dem Clash-Proxy erneut...", diff --git a/src/locales/en.json b/src/locales/en.json index e1519a2d..2716d316 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -628,7 +628,6 @@ "Unknown": "Unknown", "Auto update disabled": "Auto update disabled", "Update subscription successfully": "Update subscription successfully", - "Update failed, retrying with Clash proxy...": "Update failed, retrying with Clash proxy...", "Update with Clash proxy successfully": "Update with Clash proxy successfully", "Update failed even with Clash proxy": "Update failed even with Clash proxy", "Profile creation failed, retrying with Clash proxy...": "Profile creation failed, retrying with Clash proxy...", diff --git a/src/locales/es.json b/src/locales/es.json index e13a81c2..ede76225 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -524,7 +524,6 @@ "Unknown": "Desconocido", "Auto update disabled": "La actualización automática está deshabilitada", "Update subscription successfully": "Suscripción actualizada con éxito", - "Update failed, retrying with Clash proxy...": "Error al actualizar la suscripción. Intentando con el proxy de Clash...", "Update with Clash proxy successfully": "Actualización con el proxy de Clash exitosa", "Update failed even with Clash proxy": "Error al actualizar incluso con el proxy de Clash", "Profile creation failed, retrying with Clash proxy...": "Error al crear la suscripción. Intentando con el proxy de Clash...", diff --git a/src/locales/jp.json b/src/locales/jp.json index ae3f363e..618e4fbd 100644 --- a/src/locales/jp.json +++ b/src/locales/jp.json @@ -527,7 +527,6 @@ "Unknown": "不明", "Auto update disabled": "自動更新が無効になっています。", "Update subscription successfully": "サブスクリプションの更新に成功しました。", - "Update failed, retrying with Clash proxy...": "サブスクリプションの更新に失敗しました。Clashプロキシを使用して再試行します...", "Update with Clash proxy successfully": "Clashプロキシを使用して更新に成功しました。", "Update failed even with Clash proxy": "Clashプロキシを使用しても更新に失敗しました。", "Profile creation failed, retrying with Clash proxy...": "プロファイルの作成に失敗しました。Clashプロキシを使用して再試行します...", diff --git a/src/locales/ko.json b/src/locales/ko.json index 07173504..b5b29571 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -254,7 +254,6 @@ "Merge File Mapping Error": "병합 파일 매핑 오류", "Merge File Key Error": "병합 파일 키 오류", "Merge File Error": "병합 파일 오류", - "Update failed, retrying with Clash proxy...": "업데이트 실패, Clash 프록시로 재시도 중...", "Update with Clash proxy successfully": "Clash 프록시로 업데이트 성공", "Update failed even with Clash proxy": "Clash 프록시로도 업데이트 실패", "Failed": "실패", diff --git a/src/locales/tr.json b/src/locales/tr.json index 79ad6333..0b406488 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -574,7 +574,6 @@ "Unknown": "Bilinmiyor", "Auto update disabled": "Otomatik güncelleme devre dışı", "Update subscription successfully": "Abonelik başarıyla güncellendi", - "Update failed, retrying with Clash proxy...": "Güncelleme başarısız oldu, Clash vekil ile yeniden deneniyor...", "Update with Clash proxy successfully": "Clash vekil ile güncelleme başarılı", "Update failed even with Clash proxy": "Clash vekil ile bile güncelleme başarısız oldu", "Profile creation failed, retrying with Clash proxy...": "Profil oluşturma başarısız oldu, Clash vekil ile yeniden deneniyor...", diff --git a/src/locales/zh.json b/src/locales/zh.json index 1e320fd8..f8b161d7 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -628,7 +628,6 @@ "Unknown": "未知", "Auto update disabled": "自动更新已禁用", "Update subscription successfully": "订阅更新成功", - "Update failed, retrying with Clash proxy...": "订阅更新失败,尝试使用 Clash 代理更新", "Update with Clash proxy successfully": "使用 Clash 代理更新成功", "Update failed even with Clash proxy": "使用 Clash 代理更新也失败", "Profile creation failed, retrying with Clash proxy...": "订阅创建失败,尝试使用 Clash 代理创建", diff --git a/src/locales/zhtw.json b/src/locales/zhtw.json index fb4bc66e..efcbba3c 100644 --- a/src/locales/zhtw.json +++ b/src/locales/zhtw.json @@ -626,7 +626,6 @@ "Unknown": "未知", "Auto update disabled": "自動更新已停用", "Update subscription successfully": "訂閱更新成功", - "Update failed, retrying with Clash proxy...": "訂閱更新失敗,嘗試使用 Clash 代理更新", "Update with Clash proxy successfully": "使用 Clash 代理更新成功", "Update failed even with Clash proxy": "使用 Clash 代理更新也失敗", "Profile creation failed, retrying with Clash proxy...": "訂閱建立失敗,嘗試使用 Clash 代理建立", diff --git a/src/pages/_layout/notificationHandlers.ts b/src/pages/_layout/notificationHandlers.ts index 0f69ce30..5696b5ea 100644 --- a/src/pages/_layout/notificationHandlers.ts +++ b/src/pages/_layout/notificationHandlers.ts @@ -24,8 +24,6 @@ export const handleNoticeMessage = ( "success", `${t("Update with Clash proxy successfully")} ${msg}`, ), - update_retry_with_clash: () => - showNotice("info", t("Update failed, retrying with Clash proxy...")), update_failed_even_with_clash: () => showNotice( "error",