feat: enhance application run logic to handle macOS window reopening

This commit is contained in:
t8y2 2026-05-03 18:50:12 +08:00
parent 3c15a0bf16
commit 3cd328ece8
1 changed files with 14 additions and 3 deletions

View File

@ -4,7 +4,7 @@ mod models;
use commands::connection::AppState;
use std::sync::Arc;
use tauri::Manager;
use tauri::{Manager, RunEvent};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
@ -97,6 +97,17 @@ pub fn run() {
commands::transfer::start_transfer,
commands::transfer::cancel_transfer,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|app_handle, event| {
#[cfg(target_os = "macos")]
if let RunEvent::Reopen { has_visible_windows, .. } = &event {
if !has_visible_windows {
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
}
}
}
});
}