feat: ensure Mihomo and Verge services are running before executing commands

This commit is contained in:
Tunglies
2025-03-22 16:59:32 +08:00
parent 86f69fd574
commit 1d88d98ea1
4 changed files with 81 additions and 51 deletions

View File

@@ -47,6 +47,7 @@ pub fn change_clash_mode(mode: String) {
});
tauri::async_runtime::spawn(async move {
log::debug!(target: "app", "change clash mode to {mode}");
CoreManager::global().ensure_running_core().await;
match MihomoManager::global().patch_configs(json_value).await {
Ok(_) => {
@@ -66,6 +67,7 @@ pub fn change_clash_mode(mode: String) {
/// Test connection delay to a URL
pub async fn test_delay(url: String) -> anyhow::Result<u32> {
CoreManager::global().ensure_running_core().await;
use tokio::time::{Duration, Instant};
let mut builder = reqwest::ClientBuilder::new().use_rustls_tls().no_proxy();