Refactor async runtime usage with AsyncHandler wrapper

This commit is contained in:
Tunglies
2025-04-11 17:47:08 +08:00
parent b6a6f5f434
commit 51ef1329be
7 changed files with 55 additions and 38 deletions

View File

@@ -49,7 +49,7 @@ pub fn open_devtools(app_handle: tauri::AppHandle) {
/// 退出应用
#[tauri::command]
pub fn exit_app() {
feat::quit(Some(0));
feat::quit();
}
/// 重启应用

View File

@@ -1,5 +1,7 @@
use super::CmdResult;
use crate::{config::*, core::*, feat, module::mihomo::MihomoManager, wrap_err};
use crate::{
config::*, core::*, feat, module::mihomo::MihomoManager, process::AsyncHandler, wrap_err,
};
use serde_yaml::Mapping;
/// 复制Clash环境变量
@@ -104,10 +106,9 @@ pub fn apply_dns_config(apply: bool) -> CmdResult {
core::{handle, CoreManager},
utils::dirs,
};
use tauri::async_runtime;
// 使用spawn来处理异步操作
async_runtime::spawn(async move {
AsyncHandler::spawn(move || async move {
if apply {
// 读取DNS配置文件
let dns_path = match dirs::app_home_dir() {