mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: failed to receive shutdown signal on windows (#5533)
* fix: receive shutdown signal failed on windows * docs: update Changelog.md * chore: update * fix: use tokio runtime to handle shutdown signal * docs: update Changelog.md * fix: move tauri dependency to the correct section in Cargo.toml * fix: remove unused exit handling code in run function * fix(clash-verge-signal): use global runtime to avoid tokio runtime panic on unix * chore: update tauri-plugin-mihomo deps * fix: handle macOS exit event to ensure proper application termination --------- Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
@@ -10,9 +10,10 @@ mod feat;
|
||||
mod module;
|
||||
mod process;
|
||||
pub mod utils;
|
||||
use crate::constants::files;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::utils::linux;
|
||||
use crate::utils::resolve::init_signal;
|
||||
use crate::{constants::files, utils::resolve::prioritize_initialization};
|
||||
use crate::{
|
||||
core::handle,
|
||||
process::AsyncHandler,
|
||||
@@ -237,13 +238,14 @@ pub fn run() {
|
||||
|
||||
let builder = app_init::setup_plugins(tauri::Builder::default())
|
||||
.setup(|app| {
|
||||
logging!(info, Type::Setup, "开始应用初始化...");
|
||||
|
||||
#[allow(clippy::expect_used)]
|
||||
APP_HANDLE
|
||||
.set(app.app_handle().clone())
|
||||
.expect("failed to set global app handle");
|
||||
|
||||
let _handle = AsyncHandler::block_on(async { prioritize_initialization().await });
|
||||
|
||||
logging!(info, Type::Setup, "开始应用初始化...");
|
||||
if let Err(e) = app_init::setup_autostart(app) {
|
||||
logging!(error, Type::Setup, "Failed to setup autostart: {}", e);
|
||||
}
|
||||
@@ -257,6 +259,7 @@ pub fn run() {
|
||||
resolve::resolve_setup_handle();
|
||||
resolve::resolve_setup_async();
|
||||
resolve::resolve_setup_sync();
|
||||
init_signal();
|
||||
|
||||
logging!(info, Type::Setup, "初始化已启动");
|
||||
Ok(())
|
||||
@@ -423,6 +426,10 @@ pub fn run() {
|
||||
event_handlers::handle_reopen(has_visible_windows).await;
|
||||
});
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
tauri::RunEvent::Exit => AsyncHandler::block_on(async {
|
||||
feat::quit().await;
|
||||
}),
|
||||
tauri::RunEvent::ExitRequested { api, code, .. } => {
|
||||
AsyncHandler::block_on(async {
|
||||
let _ = handle::Handle::mihomo()
|
||||
@@ -439,13 +446,6 @@ pub fn run() {
|
||||
api.prevent_exit();
|
||||
}
|
||||
}
|
||||
tauri::RunEvent::Exit => {
|
||||
let handle = core::handle::Handle::global();
|
||||
if !handle.is_exiting() {
|
||||
handle.set_is_exiting();
|
||||
feat::clean();
|
||||
}
|
||||
}
|
||||
tauri::RunEvent::WindowEvent { label, event, .. } if label == "main" => match event {
|
||||
tauri::WindowEvent::CloseRequested { .. } => {
|
||||
event_handlers::handle_window_close(&event);
|
||||
|
||||
Reference in New Issue
Block a user