mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
* 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>
36 lines
815 B
Rust
36 lines
815 B
Rust
use std::sync::OnceLock;
|
|
|
|
use clash_verge_logging::{Type, logging};
|
|
|
|
#[cfg(unix)]
|
|
mod unix;
|
|
#[cfg(windows)]
|
|
mod windows;
|
|
|
|
pub(crate) static RUNTIME: OnceLock<Option<tokio::runtime::Runtime>> = OnceLock::new();
|
|
|
|
pub fn register<F, Fut>(#[cfg(windows)] app_handle: &tauri::AppHandle, f: F)
|
|
where
|
|
F: Fn() -> Fut + Send + Sync + 'static,
|
|
Fut: Future + Send + 'static,
|
|
{
|
|
RUNTIME.get_or_init(|| match tokio::runtime::Runtime::new() {
|
|
Ok(rt) => Some(rt),
|
|
Err(e) => {
|
|
logging!(
|
|
info,
|
|
Type::System,
|
|
"register shutdown signal failed, create tokio runtime error: {}",
|
|
e
|
|
);
|
|
None
|
|
}
|
|
});
|
|
|
|
#[cfg(unix)]
|
|
unix::register(f);
|
|
|
|
#[cfg(windows)]
|
|
windows::register(app_handle, f);
|
|
}
|