From c05d359db43188ccb5504c84d4979ca92bf5570d Mon Sep 17 00:00:00 2001 From: BTMuli Date: Sat, 23 Sep 2023 21:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=B8=BB=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E9=80=80=E5=87=BA=E6=97=B6=E5=AD=90=E7=AA=97=E5=8F=A3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/main.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5ce73150..5a8fc865 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -29,6 +29,24 @@ async fn register_deep_link(app_handle: tauri::AppHandle) { fn main() { tauri_plugin_deep_link::prepare("teyvatguide"); tauri::Builder::default() + .on_window_event(|event| { + match event.event() { + tauri::WindowEvent::CloseRequested { api, .. } => { + api.prevent_close(); + let window = event.window().clone(); + if window.label() == "TeyvatGuide" { + // 子窗口 label 的数组 + const SUB_WINDOW_LABELS: [&str; 2] = ["Sub_window", "Dev_JSON"]; + for label in SUB_WINDOW_LABELS.iter() { + let sub = window.get_window(label).unwrap(); + sub.close().unwrap(); + } + } + window.close().unwrap(); + }, + _ => {} + } + }) .plugin(tauri_plugin_sql::Builder::default().build()) .invoke_handler(tauri::generate_handler![register_deep_link]) .setup(|_app| {