🐛 debug windows close
This commit is contained in:
@@ -26,13 +26,13 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
|
||||
let mut window_builder = WebviewWindowBuilder::new(app, "pake", url)
|
||||
.title("")
|
||||
.visible(false)
|
||||
// .visible(false)
|
||||
.user_agent(user_agent)
|
||||
.resizable(window_config.resizable)
|
||||
.fullscreen(window_config.fullscreen)
|
||||
.inner_size(window_config.width, window_config.height)
|
||||
.always_on_top(window_config.always_on_top)
|
||||
.disable_drag_drop_handler()
|
||||
// .disable_drag_drop_handler()
|
||||
.initialization_script(&config_script)
|
||||
.initialization_script(include_str!("../inject/component.js"))
|
||||
.initialization_script(include_str!("../inject/event.js"))
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut};
|
||||
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||
// use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||
use util::{get_data_dir, get_pake_config};
|
||||
use window::get_window;
|
||||
|
||||
@@ -23,18 +23,18 @@ pub fn run_app() {
|
||||
|
||||
// Save the value of toggle_app_shortcut before pake_config is moved
|
||||
let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
|
||||
let init_fullscreen = pake_config.windows[0].fullscreen;
|
||||
// let init_fullscreen = pake_config.windows[0].fullscreen;
|
||||
|
||||
let window_state_plugin = if init_fullscreen {
|
||||
windowStatePlugin::default()
|
||||
.with_state_flags(tauri_plugin_window_state::StateFlags::FULLSCREEN)
|
||||
.build()
|
||||
} else {
|
||||
windowStatePlugin::default().build()
|
||||
};
|
||||
// let window_state_plugin = if init_fullscreen {
|
||||
// windowStatePlugin::default()
|
||||
// .with_state_flags(tauri_plugin_window_state::StateFlags::FULLSCREEN)
|
||||
// .build()
|
||||
// } else {
|
||||
// windowStatePlugin::default().build()
|
||||
// };
|
||||
|
||||
tauri_app
|
||||
.plugin(window_state_plugin)
|
||||
// .plugin(window_state_plugin)
|
||||
.plugin(tauri_plugin_oauth::init())
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
@@ -48,7 +48,7 @@ pub fn run_app() {
|
||||
let _window = get_window(app, &pake_config, data_dir);
|
||||
|
||||
// Prevent initial shaking
|
||||
_window.show().unwrap();
|
||||
// _window.show().unwrap();
|
||||
|
||||
if show_system_tray {
|
||||
let _ = set_system_tray(app.app_handle());
|
||||
@@ -100,24 +100,24 @@ pub fn run_app() {
|
||||
|
||||
Ok(())
|
||||
})
|
||||
// .on_window_event(|window, event| {
|
||||
// #[cfg(target_os = "macos")]
|
||||
// if let tauri::WindowEvent::CloseRequested { api, .. } = event {
|
||||
// {
|
||||
// let window_handle = window.clone();
|
||||
// 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();
|
||||
// });
|
||||
// api.prevent_close();
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
.on_window_event(|window, event| {
|
||||
#[cfg(target_os = "macos")]
|
||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
|
||||
{
|
||||
let window_handle = window.clone();
|
||||
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();
|
||||
});
|
||||
api.prevent_close();
|
||||
}
|
||||
}
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user