fix(tamagotchi): exit child process when tauri exit (#172)
This commit is contained in:
@@ -18,3 +18,20 @@ pub async fn open_settings_window(app: tauri::AppHandle) {
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn open_chat_window(app: tauri::AppHandle) {
|
||||
if let Some(window) = app.get_webview_window("chat") {
|
||||
let _ = window.show();
|
||||
return;
|
||||
}
|
||||
|
||||
let _ = WebviewWindowBuilder::new(
|
||||
&app,
|
||||
"chat",
|
||||
WebviewUrl::App(Path::new("#/chat").to_path_buf()),
|
||||
)
|
||||
.title("chat")
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::path::Path;
|
||||
use tauri::menu::{Menu, MenuItem};
|
||||
use tauri::tray::TrayIconBuilder;
|
||||
use tauri::RunEvent;
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::{ActivationPolicy, TitleBarStyle};
|
||||
use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};
|
||||
@@ -57,6 +58,7 @@ pub fn run() {
|
||||
.menu(&menu)
|
||||
.on_menu_event(|app, event| match event.id().as_ref() {
|
||||
"quit" => {
|
||||
app.cleanup_before_exit();
|
||||
app.exit(0);
|
||||
}
|
||||
"settings" => {
|
||||
@@ -90,10 +92,20 @@ pub fn run() {
|
||||
.show_menu_on_left_click(true)
|
||||
.build(app)
|
||||
.unwrap();
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![commands::open_settings_window])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::open_settings_window,
|
||||
commands::open_chat_window
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(|app_handle, event| match event {
|
||||
RunEvent::ExitRequested { .. } => {
|
||||
println!("Exiting app");
|
||||
tauri_plugin_mcp::destroy(app_handle);
|
||||
println!("Exited app");
|
||||
}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,4 +60,9 @@ export default defineConfig({
|
||||
Download('https://dist.ayaka.moe/live2d-models/hiyori_free_zh.zip', 'hiyori_free_zh.zip', 'assets/live2d/models'),
|
||||
Download('https://dist.ayaka.moe/live2d-models/hiyori_pro_zh.zip', 'hiyori_pro_zh.zip', 'assets/live2d/models'),
|
||||
],
|
||||
server: {
|
||||
watch: {
|
||||
ignored: ['**/src-tauri/**'],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user