refactor: mihomo ipc (#7601)

* refactor: mihomo ipc request

* refactor: remove redundant write locks and await on mihomo handle

* fix(rule): handle non-string types in ProviderButton labels

* refactor: handle non-string value types in RuleItem component

* refactor(tauri): remove unnecessary await in get_base_config call

* chore: update tauri-plugin-mihomo deps

* refactor: rename ConnectionId to WsConnectionId

* chore: update tauri-plugin-mihomo-api dependency reference

* chore(config): use Proxy::default in profile test initialization
This commit is contained in:
oomeow
2026-07-28 15:16:01 +00:00
committed by GitHub
parent 3515c79e2b
commit b71a1e4ec5
24 changed files with 68 additions and 134 deletions
Generated
+21 -56
View File
@@ -1616,19 +1616,6 @@ dependencies = [
"itertools 0.13.0",
]
[[package]]
name = "crossbeam"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.15"
@@ -1657,15 +1644,6 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
@@ -2341,6 +2319,15 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55"
[[package]]
name = "fast-uuid-v7"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8eaa2987e8b03da0c1659e70392d20480a595047e3db7922094ffe364e9d7b0"
dependencies = [
"rand 0.9.4",
]
[[package]]
name = "fastrand"
version = "2.4.1"
@@ -3373,7 +3360,7 @@ dependencies = [
"tokio",
"tower-service",
"tracing",
"windows-registry 0.6.1",
"windows-registry",
]
[[package]]
@@ -7270,7 +7257,7 @@ dependencies = [
"thiserror 2.0.18",
"tracing",
"url",
"windows-registry 0.5.3",
"windows-registry",
"windows-result 0.3.4",
]
@@ -7384,21 +7371,16 @@ dependencies = [
[[package]]
name = "tauri-plugin-mihomo"
version = "0.5.4"
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo?branch=fix%2Fapi-robustness#cf97ff99e390a9b437d5cf94c6f454f024fc8f69"
version = "0.5.5"
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo?branch=refactor-use-reqwest-ipc#34abd64fd3c28442f183be39f0124cb08629f443"
dependencies = [
"base64 0.22.1",
"bytes",
"crossbeam",
"arc-swap",
"fast-uuid-v7",
"futures-util",
"http 1.4.2",
"http-body-util",
"httparse",
"hyper 1.10.1",
"libc",
"log",
"percent-encoding",
"pin-project",
"rand 0.9.4",
"reqwest 0.13.4",
"serde",
"serde_json",
@@ -7408,7 +7390,6 @@ dependencies = [
"tokio",
"tokio-tungstenite",
"ts-rs",
"urlencoding",
"windows-sys 0.61.2",
]
@@ -8385,19 +8366,20 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "ts-rs"
version = "11.1.0"
version = "12.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4994acea2522cd2b3b85c1d9529a55991e3ad5e25cdcd3de9d505972c4379424"
checksum = "756050066659291d47a554a9f558125db17428b073c5ffce1daf5dcb0f7231d8"
dependencies = [
"serde_json",
"thiserror 2.0.18",
"ts-rs-macros",
]
[[package]]
name = "ts-rs-macros"
version = "11.1.0"
version = "12.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee6ff59666c9cbaec3533964505d39154dc4e0a56151fdea30a09ed0301f62e2"
checksum = "38d90eea51bc7988ef9e674bf80a85ba6804739e535e9cab48e4bb34a8b652aa"
dependencies = [
"proc-macro2",
"quote",
@@ -8557,12 +8539,6 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "urlpattern"
version = "0.3.0"
@@ -9216,17 +9192,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"
+2 -2
View File
@@ -81,7 +81,7 @@
"react-router": "^8.0.0",
"rehype-raw": "^7.0.0",
"swr": "^2.4.2",
"tauri-plugin-mihomo-api": "github:clash-verge-rev/tauri-plugin-mihomo",
"tauri-plugin-mihomo-api": "clash-verge-rev/tauri-plugin-mihomo#refactor-use-reqwest-ipc",
"types-pac": "^1.0.3",
"validator": "^13.15.35"
},
@@ -135,7 +135,7 @@
"eslint --fix --max-warnings=0",
"biome format --write"
],
"*.{css,scss,json,yaml,yml}": [
"*.{css,scss,json}": [
"biome format --write"
]
},
+5 -5
View File
@@ -126,8 +126,8 @@ importers:
specifier: ^2.4.2
version: 2.4.2(react@19.2.8)
tauri-plugin-mihomo-api:
specifier: github:clash-verge-rev/tauri-plugin-mihomo
version: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/ff75ee3edd61923e6c76a7f3cf3c3fbd0f8e22c0
specifier: clash-verge-rev/tauri-plugin-mihomo#refactor-use-reqwest-ipc
version: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/34abd64fd3c28442f183be39f0124cb08629f443
types-pac:
specifier: ^1.0.3
version: 1.0.3
@@ -3783,8 +3783,8 @@ packages:
resolution: {integrity: sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==}
engines: {node: '>=18'}
tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/ff75ee3edd61923e6c76a7f3cf3c3fbd0f8e22c0:
resolution: {gitHosted: true, tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/ff75ee3edd61923e6c76a7f3cf3c3fbd0f8e22c0}
tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/34abd64fd3c28442f183be39f0124cb08629f443:
resolution: {gitHosted: true, integrity: sha512-XTm8+iLqI+zyG4uG3yWu5xHziD+CM3KuCcJAA3pedau7tL/it4Q1KKDSlcXmdUm3KddJRQgxDnj84VMgGyFV1g==, tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/34abd64fd3c28442f183be39f0124cb08629f443}
version: 0.5.4
terser@5.49.0:
@@ -7956,7 +7956,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/ff75ee3edd61923e6c76a7f3cf3c3fbd0f8e22c0:
tauri-plugin-mihomo-api@https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/34abd64fd3c28442f183be39f0124cb08629f443:
dependencies:
'@tauri-apps/api': 2.11.1
+1 -1
View File
@@ -12,6 +12,7 @@ import {
requestDevQuit,
waitForPortClosed,
} from './dev-control.mjs'
import { windowsElevationInvocation } from './dev-service.mjs'
import {
buildTauriInvocation,
mirrorChildExit,
@@ -20,7 +21,6 @@ import {
runDevCommand,
terminateDetachedGroup,
} from './dev.mjs'
import { windowsElevationInvocation } from './dev-service.mjs'
const token = 'ab'.repeat(32)
const posixOnly = {
+1 -1
View File
@@ -33,7 +33,7 @@ async function sendTelegramNotification() {
log_info(`Download URL: ${downloadUrl}`)
// 读取发布说明和下载地址
let releaseContent = ''
let releaseContent
try {
releaseContent = readFileSync('release.txt', 'utf-8')
log_info('成功读取 release.txt 文件')
+3 -12
View File
@@ -17,10 +17,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
verge-dev = [
"clash_verge_logger/color",
"clash_verge_service_ipc/development-channel",
]
verge-dev = ["clash_verge_logger/color", "clash_verge_service_ipc/development-channel"]
dev-sidecar = ["verge-dev"]
tauri-dev = []
tokio-trace = ["console-subscriber"]
@@ -68,13 +65,7 @@ chrono = "0.4.45"
boa_engine = "0.21.1"
once_cell = { version = "1.21.4", features = ["parking_lot"] }
percent-encoding = "2.3.2"
reqwest = { version = "0.13.4", features = [
"json",
"cookies",
"gzip",
"rustls",
"form",
] }
reqwest = { version = "0.13.4", features = ["json", "cookies", "gzip", "rustls", "form"] }
regex = "1.13.1"
sysproxy = { git = "https://github.com/clash-verge-rev/sysproxy-rs", branch = "main", features = [
"guard",
@@ -100,7 +91,7 @@ backon = { version = "1.6.0", features = ["tokio-sleep"] }
tauri-plugin-http = "2.5.9"
console-subscriber = { version = "0.5.0", optional = true }
tauri-plugin-devtools = { version = "2.1.0" }
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo", branch = "fix/api-robustness" }
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo", branch = "refactor-use-reqwest-ipc" }
clash_verge_logger = { git = "https://github.com/clash-verge-rev/clash-verge-logger" }
async-trait = "0.1.91"
# Tracks a branch until the protocol change it carries is tagged; move this to v2.6.0 then.
+1 -2
View File
@@ -41,9 +41,8 @@ pub async fn get_proxy_view() -> CmdResult<ProxyViewV1> {
let latest_runtime = runtime.latest_arc();
let runtime_group_order = runtime_group_order(latest_runtime.config.as_ref());
let mihomo = Handle::mihomo().await;
let mihomo = Handle::mihomo();
let (proxies, providers) = tokio::join!(mihomo.get_proxies(), mihomo.get_proxy_providers(),);
drop(mihomo);
let proxies = proxies.stringify_err()?;
Ok(ProxyViewBuilder::build(ProxyViewInput {
+1 -1
View File
@@ -43,7 +43,7 @@ impl MixedPort {
pub async fn effective() -> u16 {
let desired = Self::desired().await;
resolve_effective(
|| async { Ok(Handle::mihomo().await.get_base_config().await?.mixed_port) },
|| async { Ok(Handle::mihomo().get_base_config().await?.mixed_port) },
desired,
)
.await
+1 -1
View File
@@ -245,7 +245,7 @@ async fn owned_service_core_uses_port(port: u16) -> bool {
return false;
}
match Handle::mihomo().await.get_base_config().await {
match Handle::mihomo().get_base_config().await {
Ok(config) => config.mixed_port == port,
Err(error) => {
logging!(
+2 -5
View File
@@ -758,7 +758,7 @@ fn is_activation_current(generation: u64) -> bool {
async fn fetch_proxies_with_timeout() -> Result<Proxies> {
tokio::time::timeout(MIHOMO_OPERATION_TIMEOUT, async {
loop {
match handle::Handle::mihomo().await.get_proxies().await {
match handle::Handle::mihomo().get_proxies().await {
Ok(proxies) => return proxies,
Err(err) => {
logging!(debug, Type::Config, "mihomo proxies are not ready yet: {err}");
@@ -773,10 +773,7 @@ async fn fetch_proxies_with_timeout() -> Result<Proxies> {
async fn select_node_with_timeout(group_name: &String, node: &String) -> Result<()> {
tokio::time::timeout(MIHOMO_OPERATION_TIMEOUT, async {
handle::Handle::mihomo()
.await
.select_node_for_group(group_name, node)
.await
handle::Handle::mihomo().select_node_for_group(group_name, node).await
})
.await
.with_context(|| format!("timed out while selecting node [{node}] for group [{group_name}]"))?
+2 -3
View File
@@ -3,7 +3,6 @@ use smartstring::alias::String;
use std::sync::atomic::{AtomicBool, Ordering};
use tauri::AppHandle;
use tauri_plugin_mihomo::{Mihomo, MihomoExt as _};
use tokio::sync::RwLockReadGuard;
use super::notification::{FrontendEvent, NotificationSystem};
@@ -32,8 +31,8 @@ impl Handle {
APP_HANDLE.get().expect("App handle not initialized")
}
pub async fn mihomo() -> RwLockReadGuard<'static, Mihomo> {
Self::app_handle().mihomo().read().await
pub fn mihomo() -> &'static Mihomo {
Self::app_handle().mihomo()
}
pub fn refresh_clash() {
+1 -1
View File
@@ -326,7 +326,7 @@ impl CoreManager {
}
async fn reload_config(&self, path: &str) -> Result<(), MihomoError> {
handle::Handle::mihomo().await.reload_config(true, path).await
handle::Handle::mihomo().reload_config(true, path).await
}
}
+1 -5
View File
@@ -80,8 +80,6 @@ impl CoreManager {
let sidecar_ipc = dirs::sidecar_ipc_path()?;
handle::Handle::app_handle()
.mihomo()
.write()
.await
.update_socket_path(dirs::path_to_str(&sidecar_ipc)?.to_owned())?;
let config_file = Config::generate_file(crate::config::ConfigType::Run).await?;
let app_handle = handle::Handle::app_handle();
@@ -139,7 +137,7 @@ impl CoreManager {
let readiness = poll_sidecar_readiness(SIDECAR_READINESS_ATTEMPTS, SIDECAR_READINESS_INTERVAL, || async {
tokio::time::timeout(SIDECAR_READINESS_PROBE_TIMEOUT, async {
handle::Handle::mihomo().await.get_version().await
handle::Handle::mihomo().get_version().await
})
.await
.context("Mihomo readiness probe timed out")??;
@@ -236,8 +234,6 @@ impl CoreManager {
let config_file = Config::generate_file(crate::config::ConfigType::Run).await?;
handle::Handle::app_handle()
.mihomo()
.write()
.await
.update_socket_path(dirs::path_to_str(&service_ipc)?.to_owned())?;
self.start_core_by_service_with_config(&config_file).await
+1 -1
View File
@@ -1114,7 +1114,7 @@ fn start_owner_monitor() {
preserving local proxy state while the core endpoint still answers"
);
}
let owner_endpoint_available = Handle::mihomo().await.get_version().await.is_ok();
let owner_endpoint_available = Handle::mihomo().get_version().await.is_ok();
step = watch.resolve_transport(owner_endpoint_available);
}
+5 -7
View File
@@ -609,12 +609,10 @@ async fn create_tray_menu(
// TODO: should update tray menu again when it was timeout error
let (proxy_nodes_data, runtime_proxy_groups_order) = if options.include_proxy_groups {
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 proxy_nodes_data =
tokio::time::timeout(Duration::from_millis(1000), handle::Handle::mihomo().get_proxies())
.await
.map_or(None, |res| res.ok());
let runtime_proxy_groups_order = cmd::get_runtime_config()
.await
@@ -973,7 +971,7 @@ fn on_menu_event(_: &AppHandle, event: MenuEvent) {
feat::toggle_tun_mode(None).await;
}
MenuIds::CLOSE_ALL_CONNECTIONS => {
if let Err(err) = handle::Handle::mihomo().await.close_all_connections().await {
if let Err(err) = handle::Handle::mihomo().close_all_connections().await {
logging!(error, Type::Tray, "Failed to close all connections from tray: {err}");
}
}
+6 -6
View File
@@ -6,7 +6,7 @@ use parking_lot::Mutex;
use std::sync::Arc;
use std::time::Duration;
use tauri::async_runtime::JoinHandle;
use tauri_plugin_mihomo::models::ConnectionId;
use tauri_plugin_mihomo::models::WsConnectionId;
/// 托盘速率流异常后的重连间隔。
const TRAY_SPEED_RETRY_DELAY: Duration = Duration::from_secs(1);
@@ -19,7 +19,7 @@ const TRAY_SPEED_STALE_TIMEOUT: Duration = Duration::from_secs(5);
#[derive(Clone)]
pub struct TraySpeedController {
speed_task: Arc<Mutex<Option<JoinHandle<()>>>>,
speed_connection_id: Arc<Mutex<Option<ConnectionId>>>,
speed_connection_id: Arc<Mutex<Option<WsConnectionId>>>,
}
impl Default for TraySpeedController {
@@ -162,17 +162,17 @@ impl TraySpeedController {
}
fn set_speed_connection_id(
speed_connection_id: &Arc<Mutex<Option<ConnectionId>>>,
connection_id: Option<ConnectionId>,
speed_connection_id: &Arc<Mutex<Option<WsConnectionId>>>,
connection_id: Option<WsConnectionId>,
) {
*speed_connection_id.lock() = connection_id;
}
fn take_speed_connection_id(speed_connection_id: &Arc<Mutex<Option<ConnectionId>>>) -> Option<ConnectionId> {
fn take_speed_connection_id(speed_connection_id: &Arc<Mutex<Option<WsConnectionId>>>) -> Option<WsConnectionId> {
speed_connection_id.lock().take()
}
async fn disconnect_speed_connection(speed_connection_id: &Arc<Mutex<Option<ConnectionId>>>) {
async fn disconnect_speed_connection(speed_connection_id: &Arc<Mutex<Option<WsConnectionId>>>) {
if let Some(connection_id) = Self::take_speed_connection_id(speed_connection_id) {
connections_stream::disconnect_connection(connection_id).await;
}
+2 -3
View File
@@ -68,14 +68,13 @@ pub async fn restart_app() {
fn after_change_clash_mode() {
AsyncHandler::spawn(move || async {
let mihomo = handle::Handle::mihomo().await;
let mihomo = handle::Handle::mihomo();
match mihomo.get_connections().await {
Ok(connections) => {
if let Some(connections_array) = connections.connections {
for connection in connections_array {
let _ = mihomo.close_connection(&connection.id).await;
}
drop(mihomo);
}
}
Err(err) => {
@@ -97,7 +96,7 @@ pub async fn change_clash_mode(mode: String) -> Result<(), String> {
"mode": mode
});
logging!(debug, Type::Core, "change clash mode to {mode}");
if let Err(err) = handle::Handle::mihomo().await.patch_base_config(&json_value).await {
if let Err(err) = handle::Handle::mihomo().patch_base_config(&json_value).await {
logging!(error, Type::Core, "{err}");
return Err(err.to_string().into());
}
-2
View File
@@ -19,7 +19,6 @@ pub async fn toggle_proxy_profile(profile_index: String) {
pub async fn switch_proxy_node(group_name: &str, proxy_name: &str) {
match handle::Handle::mihomo()
.await
.select_node_for_group(group_name, proxy_name)
.await
{
@@ -42,7 +41,6 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str) {
}
match handle::Handle::mihomo()
.await
.select_node_for_group(group_name, proxy_name)
.await
{
+1 -1
View File
@@ -15,7 +15,7 @@ pub async fn toggle_system_proxy() -> bool {
// 如果当前系统代理即将关闭,且自动关闭连接设置为true,则关闭所有连接
if current
&& auto_close_connection
&& let Err(err) = handle::Handle::mihomo().await.close_all_connections().await
&& let Err(err) = handle::Handle::mihomo().close_all_connections().await
{
logging!(error, Type::ProxyMode, "Failed to close all connections: {err}");
}
-10
View File
@@ -24,7 +24,6 @@ use tauri::{AppHandle, Manager as _};
#[cfg(target_os = "macos")]
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_deep_link::DeepLinkExt as _;
use tauri_plugin_mihomo::RejectPolicy;
pub static APP_HANDLE: OnceCell<AppHandle> = OnceCell::new();
/// Application initialization helper functions
@@ -59,15 +58,6 @@ mod app_init {
tauri_plugin_mihomo::Builder::new()
.protocol(tauri_plugin_mihomo::models::Protocol::LocalSocket)
.socket_path(crate::config::IClashTemp::guard_external_controller_ipc())
.pool_config(
tauri_plugin_mihomo::IpcPoolConfigBuilder::new()
.min_connections(3)
.max_connections(32)
.idle_timeout(std::time::Duration::from_secs(60))
.health_check_interval(std::time::Duration::from_secs(60))
.reject_policy(RejectPolicy::Wait)
.build(),
)
.build(),
);
+3 -5
View File
@@ -2,7 +2,7 @@ use crate::{Type, core::handle, logging};
use anyhow::Result;
use serde::Deserialize;
use std::time::Duration;
use tauri_plugin_mihomo::models::ConnectionId;
use tauri_plugin_mihomo::models::WsConnectionId;
use tokio::sync::mpsc;
use tokio::time::Instant;
@@ -37,7 +37,7 @@ enum InternalWsEvent<T> {
/// Mihomo WebSocket 订阅句柄(通用事件流)。
pub struct MihomoWsEventStream<T> {
/// 当前订阅连接 ID,用于主动断开。
pub connection_id: ConnectionId,
pub connection_id: WsConnectionId,
/// 当前订阅消息接收器。
receiver: mpsc::Receiver<InternalWsEvent<T>>,
/// 最近一次收到有效事件的时间戳。
@@ -75,7 +75,6 @@ pub async fn connect_traffic_stream() -> Result<MihomoWsEventStream<TrafficSpeed
let (message_tx, message_rx) = mpsc::channel::<InternalWsEvent<TrafficSpeedEvent>>(MIHOMO_WS_STREAM_BUFFER_SIZE);
// 建立 Mihomo `/traffic` WebSocket 订阅。
let connection_id = handle::Handle::mihomo()
.await
.ws_traffic({
let message_tx = message_tx.clone();
move |message| {
@@ -143,9 +142,8 @@ impl<T> MihomoWsEventStream<T> {
///
/// # Arguments
/// * `connection_id` - 目标连接 ID
pub async fn disconnect_connection(connection_id: ConnectionId) {
pub async fn disconnect_connection(connection_id: WsConnectionId) {
if let Err(err) = handle::Handle::mihomo()
.await
.disconnect(connection_id, Some(MIHOMO_WS_STREAM_CLOSE_CODE))
.await
{
+1 -1
View File
@@ -185,7 +185,7 @@ pub fn on_web_content_process_terminated(webview: &tauri::Webview) {
// reload 必须与清理同任务、排在其后,否则清理可能误清重载后新页面的订阅(竞态)。
let webview = webview.clone();
crate::process::AsyncHandler::spawn(move || async move {
if let Err(err) = handle::Handle::mihomo().await.clear_all_ws_connections().await {
if let Err(err) = handle::Handle::mihomo().clear_all_ws_connections().await {
logging!(warn, Type::Window, "清理 Mihomo WebSocket 连接失败: {err}");
} else {
logging!(info, Type::Window, "已清理全部 Mihomo WebSocket 连接");
+6 -2
View File
@@ -235,10 +235,14 @@ export const ProviderButton = () => {
secondary={
<Box sx={{ display: 'flex' }}>
<TypeBox component="span">
{provider.vehicleType}
{typeof provider.vehicleType === 'string'
? provider.vehicleType
: provider.vehicleType.Unknown}
</TypeBox>
<TypeBox component="span">
{provider.behavior}
{typeof provider.behavior === 'string'
? provider.behavior
: provider.behavior.Unknown}
</TypeBox>
</Box>
}
+1 -1
View File
@@ -54,7 +54,7 @@ const RuleItem = (props: Props) => {
color="text.secondary"
sx={{ mr: 3, minWidth: 120, display: 'inline-block' }}
>
{value.type}
{typeof value.type === 'string' ? value.type : value.type.Unknown}
</Typography>
<Typography