From 3ab985aacc111929d93aa7aaa8c80c23e772a032 Mon Sep 17 00:00:00 2001 From: oomeow Date: Sun, 7 Dec 2025 12:42:32 +0800 Subject: [PATCH] fix: failed to restart core (#5754) * fix: failed to restart core after install service * chore: update tauri-plugin-mihomo deps * fix: update dependencies for tauri-plugin-mihomo and related packages --------- Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com> --- Cargo.lock | 29 +++++++++-------------------- pnpm-lock.yaml | 8 ++++---- src-tauri/src/core/service.rs | 6 ++++-- src-tauri/src/core/tray/mod.rs | 8 +++++++- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21d5981e3..6af53c014 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1372,7 +1372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -3547,12 +3547,12 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.1", + "socket2 0.5.10", "system-configuration", "tokio", "tower-service", "tracing", - "windows-registry 0.6.1", + "windows-registry", ] [[package]] @@ -5165,7 +5165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] @@ -5955,7 +5955,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2 0.6.1", + "socket2 0.5.10", "thiserror 2.0.17", "tokio", "tracing", @@ -5992,7 +5992,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.1", + "socket2 0.5.10", "tracing", "windows-sys 0.60.2", ] @@ -7720,7 +7720,7 @@ dependencies = [ "thiserror 2.0.17", "tracing", "url", - "windows-registry 0.5.3", + "windows-registry", "windows-result 0.3.4", ] @@ -7833,7 +7833,7 @@ dependencies = [ [[package]] name = "tauri-plugin-mihomo" version = "0.1.1" -source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo#85fc6b364227e69f5b1cfeb8ca82642c153b5210" +source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo#153f16f7b3f979aa130a2d3d7c39a52a39987288" dependencies = [ "base64 0.22.1", "futures-util", @@ -9474,7 +9474,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] @@ -9654,17 +9654,6 @@ dependencies = [ "windows-strings 0.4.2", ] -[[package]] -name = "windows-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" -dependencies = [ - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", -] - [[package]] name = "windows-result" version = "0.3.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e5a0047f..69e3b744c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,7 +127,7 @@ importers: version: 2.3.7(react@19.2.1) tauri-plugin-mihomo-api: specifier: git+https://github.com/clash-verge-rev/tauri-plugin-mihomo#main - version: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/85fc6b364227e69f5b1cfeb8ca82642c153b5210 + version: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/153f16f7b3f979aa130a2d3d7c39a52a39987288 types-pac: specifier: ^1.0.3 version: 1.0.3 @@ -3825,8 +3825,8 @@ packages: resolution: {integrity: sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==} engines: {node: '>=18'} - tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/85fc6b364227e69f5b1cfeb8ca82642c153b5210: - resolution: {tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/85fc6b364227e69f5b1cfeb8ca82642c153b5210} + tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/153f16f7b3f979aa130a2d3d7c39a52a39987288: + resolution: {tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/153f16f7b3f979aa130a2d3d7c39a52a39987288} version: 0.1.0 terser@5.44.1: @@ -8248,7 +8248,7 @@ snapshots: minizlib: 3.1.0 yallist: 5.0.0 - tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/85fc6b364227e69f5b1cfeb8ca82642c153b5210: + tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/153f16f7b3f979aa130a2d3d7c39a52a39987288: dependencies: '@tauri-apps/api': 2.9.1 diff --git a/src-tauri/src/core/service.rs b/src-tauri/src/core/service.rs index 1356432f0..0234df75b 100644 --- a/src-tauri/src/core/service.rs +++ b/src-tauri/src/core/service.rs @@ -1,6 +1,6 @@ use crate::{ config::{Config, IClashTemp}, - core::tray, + core::Timer, utils::{dirs, init::service_writer_config}, }; use anyhow::{Context as _, Result, bail}; @@ -568,7 +568,9 @@ impl ServiceManager { return Err(anyhow::anyhow!("服务不可用: {}", reason)); } } - let _ = tray::Tray::global().update_menu().await; + + // 防止服务安装成功后,内核未完全启动导致系统托盘无法获取代理节点信息 + Timer::global().add_update_tray_menu_task()?; Ok(()) } } diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index 360c6fb10..35ca49d92 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -722,7 +722,13 @@ async fn create_tray_menu( i18n::sync_locale().await; - let proxy_nodes_data = handle::Handle::mihomo().await.get_proxies().await.ok(); + // TODO: mihomo 请求的超时机制未起作用,需要排查 + let proxy_nodes_data = tokio::time::timeout( + Duration::from_millis(1000), + handle::Handle::mihomo().await.get_proxies(), + ) + .await + .map_or(None, |res| res.ok()); let runtime_proxy_groups_order = cmd::get_runtime_config() .await