refactor: use async instead of block_on

This commit is contained in:
MystiPanda
2024-06-29 19:02:37 +08:00
parent 041522f94e
commit b85929772e
11 changed files with 81 additions and 74 deletions

View File

@@ -15,8 +15,15 @@ use tauri::{api, SystemTray};
fn main() -> std::io::Result<()> {
// 单例检测
if server::check_singleton().is_err() {
println!("app exists");
let app_exists: bool = tauri::async_runtime::block_on(async move {
if server::check_singleton().await.is_err() {
println!("app exists");
true
} else {
false
}
});
if app_exists {
return Ok(());
}
@@ -29,7 +36,9 @@ fn main() -> std::io::Result<()> {
let mut builder = tauri::Builder::default()
.system_tray(SystemTray::new())
.setup(|app| {
resolve::resolve_setup(app);
tauri::async_runtime::block_on(async move {
resolve::resolve_setup(app).await;
});
Ok(())
})
.on_system_tray_event(core::tray::Tray::on_system_tray_event)