From 65063424db1347333249a37267afb51d4478e6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Sat, 27 Jan 2024 19:11:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E7=9A=84=20panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a7760d32..dace8d5d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -56,8 +56,11 @@ async fn register_deep_link(app_handle: tauri::AppHandle) { // 执行 js #[tauri::command] async fn execute_js(app_handle: tauri::AppHandle, label: String, js: String) { - let window = app_handle.get_window(&label).unwrap(); - window.eval(&js).ok().unwrap(); + let window = app_handle.get_window(&label); + if window.is_none() { + return; + } + window.unwrap().eval(&js).ok().unwrap(); } // 创建窗口