✨ add new param hide-on-close
This commit is contained in:
@@ -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)]
|
||||
|
||||
8
src-tauri/src/inject/style.js
vendored
8
src-tauri/src/inject/style.js
vendored
@@ -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;
|
||||
|
||||
@@ -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!())
|
||||
|
||||
Reference in New Issue
Block a user