mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 03:03:46 +08:00
fix: performance issues caused by closing windows on mac
This commit is contained in:
parent
c35ab2e1cd
commit
ac884da56b
@ -30,9 +30,12 @@ impl Handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window(&self) -> Option<WebviewWindow> {
|
pub fn get_window(&self) -> Option<WebviewWindow> {
|
||||||
self.app_handle()
|
let app_handle = self.app_handle().unwrap();
|
||||||
.as_ref()
|
let window: Option<WebviewWindow> = app_handle.get_webview_window("main");
|
||||||
.and_then(|a| a.get_webview_window("main"))
|
if window.is_none() {
|
||||||
|
log::debug!(target:"app", "main window not found");
|
||||||
|
}
|
||||||
|
window
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_clash() {
|
pub fn refresh_clash() {
|
||||||
|
@ -141,8 +141,11 @@ pub fn run() {
|
|||||||
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
||||||
if label == "main" {
|
if label == "main" {
|
||||||
match event {
|
match event {
|
||||||
tauri::WindowEvent::CloseRequested { .. } => {
|
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||||
println!("closing window...");
|
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);
|
let _ = resolve::save_window_size_position(true);
|
||||||
}
|
}
|
||||||
tauri::WindowEvent::Moved(_) | tauri::WindowEvent::Resized(_) => {
|
tauri::WindowEvent::Moved(_) | tauri::WindowEvent::Resized(_) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user