refactor: Remove Rust window handler and migrate to the JS ones

This commit is contained in:
LynithDev 2024-03-16 13:16:29 +01:00
parent 197b52a168
commit 59f4b2ef16
2 changed files with 3 additions and 13 deletions

View file

@ -4,28 +4,17 @@
use std::error::Error;
use polyfrost_launcher::auth;
use tauri::{App, Manager};
use tauri::App;
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(auth::init())
.setup(setup)
.on_window_event(window_handler)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
fn window_handler(window: &tauri::Window, event: &tauri::WindowEvent) {
match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
api.prevent_close();
let _ = window.emit("handle_window_close_request", ());
}
_ => {}
}
}
fn setup(_: &mut App) -> Result<(), Box<dyn Error>> {
Ok(())
}

View file

@ -27,7 +27,8 @@ function WindowFrame() {
const minimize = () => Window.getCurrent().minimize();
const quit = () => Window.getCurrent().destroy();
Window.getCurrent().listen('handle_window_close_request', () => {
Window.getCurrent().onCloseRequested((event) => {
event.preventDefault();
setModalVisible(true);
});