fix: performance issues caused by closing windows on mac

This commit is contained in:
huzibaca 2024-10-30 06:27:29 +08:00
parent 94c437c3e3
commit d10323701a
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302
2 changed files with 10 additions and 4 deletions

View File

@ -30,9 +30,12 @@ impl Handle {
}
pub fn get_window(&self) -> Option<WebviewWindow> {
self.app_handle()
.as_ref()
.and_then(|a| a.get_webview_window("main"))
let app_handle = self.app_handle().unwrap();
let window: Option<WebviewWindow> = app_handle.get_webview_window("main");
if window.is_none() {
log::debug!(target:"app", "main window not found");
}
window
}
pub fn refresh_clash() {

View File

@ -141,8 +141,11 @@ pub fn run() {
tauri::RunEvent::WindowEvent { label, event, .. } => {
if label == "main" {
match event {
tauri::WindowEvent::CloseRequested { .. } => {
tauri::WindowEvent::CloseRequested { api, .. } => {
println!("closing window...");
api.prevent_close();
let window = core::handle::Handle::global().get_window().unwrap();
log_err!(window.minimize());
let _ = resolve::save_window_size_position(true);
}
tauri::WindowEvent::Moved(_) | tauri::WindowEvent::Resized(_) => {