From 3bb708233e929c96fd0333937229cc2aed18e07a Mon Sep 17 00:00:00 2001
From: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Tue, 27 Oct 2026 17:52:24 +0800
Subject: [PATCH 01/51] refactor(utils): drop dead reset helper and tidy
init_resources
- remove resolve_reset_async, which had no callers
- drop the duplicated time.*.com entry from the default fake-ip-filter
- init_resources no longer recreates app_home (ensure_directories during
init_config already created it) and now propagates res_dir creation errors
---
src-tauri/src/utils/init.rs | 7 ++-----
src-tauri/src/utils/resolve/mod.rs | 14 --------------
2 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/src-tauri/src/utils/init.rs b/src-tauri/src/utils/init.rs
index be7f016a1..927fc797f 100644
--- a/src-tauri/src/utils/init.rs
+++ b/src-tauri/src/utils/init.rs
@@ -354,7 +354,6 @@ pub(super) async fn init_dns_config() -> Result<()> {
Value::String("*.arpa".into()),
Value::String("time.*.com".into()),
Value::String("ntp.*.com".into()),
- Value::String("time.*.com".into()),
Value::String("+.market.xiaomi.com".into()),
Value::String("localhost.ptlogin2.qq.com".into()),
Value::String("*.msftncsi.com".into()),
@@ -509,11 +508,9 @@ pub async fn init_resources() -> Result<()> {
let app_dir = dirs::app_home_dir()?;
let res_dir = dirs::app_resources_dir()?;
- if !app_dir.exists() {
- std::mem::drop(fs::create_dir_all(&app_dir).await);
- }
+ // app_home is created by `ensure_directories` in `init_config`, which always runs first.
if !res_dir.exists() {
- std::mem::drop(fs::create_dir_all(&res_dir).await);
+ fs::create_dir_all(&res_dir).await?;
}
let file_list = ["Country.mmdb", "ASN.mmdb", "geoip.dat", "geosite.dat"];
diff --git a/src-tauri/src/utils/resolve/mod.rs b/src-tauri/src/utils/resolve/mod.rs
index 7ba959ae3..fa408f2af 100644
--- a/src-tauri/src/utils/resolve/mod.rs
+++ b/src-tauri/src/utils/resolve/mod.rs
@@ -1,8 +1,6 @@
use crate::core::notify::NoticeStatus;
use std::sync::atomic::{AtomicBool, Ordering};
-use anyhow::Result;
-
use crate::{
config::Config,
core::{
@@ -97,18 +95,6 @@ async fn resolve_setup() {
resolve_done();
}
-pub async fn resolve_reset_async() -> Result<(), anyhow::Error> {
- CoreManager::global().stop_core().await?;
-
- #[cfg(target_os = "macos")]
- {
- use dns::restore_public_dns;
- restore_public_dns().await?;
- }
-
- Ok(())
-}
-
fn init_scheme() {
logging_error!(Type::Setup, init::init_scheme());
}
From dbaee8a5e453897b83c82508d33c784c03863498 Mon Sep 17 00:00:00 2001
From: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Tue, 27 Oct 2026 17:58:27 +0800
Subject: [PATCH 02/51] refactor(profile): remove identical blind retry when
switching node
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The second select_node_for_group call in switch_proxy_node was a
zero-interval retry with identical arguments. Its success path was a
degraded copy of the first (missing the Refresh::Proxies announcement
ever since the old force-refresh emit was removed), and its distinct
"回退/最终失败" log wording misled maintainers. Keep a single call,
the primary success aftermath, and one error log.
---
src-tauri/src/feat/profile.rs | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/src-tauri/src/feat/profile.rs b/src-tauri/src/feat/profile.rs
index 56faeb01d..a74e7dd39 100644
--- a/src-tauri/src/feat/profile.rs
+++ b/src-tauri/src/feat/profile.rs
@@ -47,26 +47,11 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str) {
record_switched_node(group_name, proxy_name).await;
announce(Refresh::Proxies);
let _ = tray::Tray::global().update_menu().await;
- return;
}
Err(err) => {
logging!(error, Type::Tray, "切换代理失败: {err:?}");
}
}
-
- match handle::Handle::mihomo()
- .select_node_for_group(group_name, proxy_name)
- .await
- {
- Ok(_) => {
- logging!(info, Type::Tray, "代理切换回退成功: {} -> {}", group_name, proxy_name);
- record_switched_node(group_name, proxy_name).await;
- let _ = tray::Tray::global().update_menu().await;
- }
- Err(err) => {
- logging!(error, Type::Tray, "代理切换最终失败: {err:?}");
- }
- }
}
async fn should_update_profile(uid: &String, ignore_auto_update: bool) -> Result