fix: resolve crashes when exiting lightweight mode by ensuring async window operations

This commit is contained in:
Tunglies
2025-08-30 20:04:21 +08:00
parent c09066c0a3
commit 92d9c94e87
5 changed files with 20 additions and 18 deletions

View File

@@ -362,7 +362,7 @@ pub fn run() {
/// Handle application reopen events (macOS)
#[cfg(target_os = "macos")]
pub fn handle_reopen(app_handle: &AppHandle, has_visible_windows: bool) {
pub async fn handle_reopen(app_handle: &AppHandle, has_visible_windows: bool) {
logging!(
info,
Type::System,
@@ -379,7 +379,7 @@ pub fn run() {
logging!(info, Type::System, true, "没有可见窗口,尝试显示主窗口");
let result = WindowManager::show_main_window();
let result = WindowManager::show_main_window().await;
logging!(
info,
Type::System,
@@ -538,7 +538,10 @@ pub fn run() {
has_visible_windows,
..
} => {
event_handlers::handle_reopen(app_handle, has_visible_windows);
let app_handle = app_handle.clone();
AsyncHandler::spawn(move || async move {
event_handlers::handle_reopen(&app_handle, has_visible_windows).await;
});
}
tauri::RunEvent::ExitRequested { api, code, .. } => {
if code.is_none() {