add new param hide-on-close

This commit is contained in:
Tw93
2025-08-05 15:17:02 +08:00
parent d8b8102367
commit 4a91c42e2e
16 changed files with 1223 additions and 1136 deletions

View File

@@ -13,6 +13,7 @@ pub struct WindowConfig {
pub dark_mode: bool,
pub disabled_web_shortcuts: bool,
pub activation_shortcut: String,
pub hide_on_close: bool,
}
#[derive(Debug, Serialize, Deserialize)]

View File

@@ -284,6 +284,14 @@ window.addEventListener('DOMContentLoaded', _event => {
margin: 0;
display: inline;
}
.AppHeader .AppHeader-globalBar.js-global-bar {
padding-top: 35px;
}
.header-overlay .header-logged-out {
margin-top: 15px;
}
`;
const contentStyleElement = document.createElement('style');
contentStyleElement.innerHTML = contentCSS;

View File

@@ -21,6 +21,7 @@ pub fn run_app() {
let tauri_app = tauri::Builder::default();
let show_system_tray = pake_config.show_system_tray();
let hide_on_close = pake_config.windows[0].hide_on_close;
let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
let init_fullscreen = pake_config.windows[0].fullscreen;
@@ -54,19 +55,24 @@ pub fn run_app() {
window.show().unwrap();
Ok(())
})
.on_window_event(|_window, _event| {
#[cfg(target_os = "macos")]
.on_window_event(move |_window, _event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = _event {
let window = _window.clone();
tauri::async_runtime::spawn(async move {
if window.is_fullscreen().unwrap_or(false) {
window.set_fullscreen(false).unwrap();
tokio::time::sleep(Duration::from_millis(900)).await;
}
window.minimize().unwrap();
window.hide().unwrap();
});
api.prevent_close();
if hide_on_close {
let window = _window.clone();
tauri::async_runtime::spawn(async move {
#[cfg(target_os = "macos")]
{
if window.is_fullscreen().unwrap_or(false) {
window.set_fullscreen(false).unwrap();
tokio::time::sleep(Duration::from_millis(900)).await;
}
}
window.minimize().unwrap();
window.hide().unwrap();
});
api.prevent_close();
}
// If hide_on_close is false, allow normal close behavior
}
})
.run(tauri::generate_context!())