🐛 Resolve the issue of closing full screen on Mac.
This commit is contained in:
15
src-tauri/Cargo.lock
generated
15
src-tauri/Cargo.lock
generated
@@ -73,6 +73,7 @@ dependencies = [
|
|||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tauri-plugin-oauth",
|
"tauri-plugin-oauth",
|
||||||
"tauri-plugin-window-state",
|
"tauri-plugin-window-state",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4145,11 +4146,25 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
|
"tokio-macros",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-macros"
|
||||||
|
version = "2.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.65",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-native-tls"
|
name = "tokio-native-tls"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ serde = { version = "1.0.202", features = ["derive"] }
|
|||||||
tauri = { version = "1.6.6", features = ["api-all", "system-tray"] }
|
tauri = { version = "1.6.6", features = ["api-all", "system-tray"] }
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "main" }
|
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "main" }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
cargo-bloat = "0.11.1"
|
cargo-bloat = "0.11.1"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ mod util;
|
|||||||
use app::{invoke, menu, window};
|
use app::{invoke, menu, window};
|
||||||
use invoke::{download_file, download_file_by_binary};
|
use invoke::{download_file, download_file_by_binary};
|
||||||
use menu::{get_system_tray, system_tray_handle};
|
use menu::{get_system_tray, system_tray_handle};
|
||||||
|
use std::time::Duration;
|
||||||
use tauri::{GlobalShortcutManager, Manager};
|
use tauri::{GlobalShortcutManager, Manager};
|
||||||
use util::{get_data_dir, get_pake_config};
|
use util::{get_data_dir, get_pake_config};
|
||||||
use window::build_window;
|
use window::build_window;
|
||||||
@@ -61,14 +62,24 @@ pub fn run_app() {
|
|||||||
})
|
})
|
||||||
.on_window_event(|event| {
|
.on_window_event(|event| {
|
||||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
|
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
|
||||||
|
let window = event.window();
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
event.window().minimize().unwrap();
|
let window_handle = window.clone();
|
||||||
event.window().hide().unwrap();
|
tauri::async_runtime::spawn(async move {
|
||||||
|
if window_handle.is_fullscreen().unwrap_or(false) {
|
||||||
|
window_handle.set_fullscreen(false).unwrap();
|
||||||
|
// Give a small delay to ensure the full-screen exit operation is completed.
|
||||||
|
tokio::time::sleep(Duration::from_millis(900)).await;
|
||||||
|
}
|
||||||
|
window_handle.minimize().unwrap();
|
||||||
|
window_handle.hide().unwrap();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
event.window().close().unwrap();
|
window.close().unwrap();
|
||||||
|
|
||||||
api.prevent_close();
|
api.prevent_close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user