Fix killing command on Windows

This commit is contained in:
Gregory Schier
2024-07-28 15:40:19 -07:00
parent 410cb7969c
commit f91dd24a9b
3 changed files with 14 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ extern crate core;
use crate::manager::PluginManager;
use log::info;
use std::process::exit;
use tauri::plugin::{Builder, TauriPlugin};
use tauri::{Manager, RunEvent, Runtime, State};
use tokio::sync::Mutex;
@@ -25,11 +26,13 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
})
.on_event(|app, e| match e {
// TODO: Also exit when app is force-quit (eg. cmd+r in IntelliJ runner)
RunEvent::Exit => {
RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
tauri::async_runtime::block_on(async move {
info!("Exiting plugin runtime due to app exit");
let manager: State<Mutex<PluginManager>> = app.state();
manager.lock().await.cleanup().await;
exit(0);
});
}
_ => {}