瀏覽代碼

fix(tauri) window.tauri is undefined upon reloading (#377) (#453)

Shihpin Tseng 5 年之前
父節點
當前提交
d79eb4fc21
共有 2 個文件被更改,包括 4 次插入0 次删除
  1. 3 0
      tauri/src/endpoints.rs
  2. 1 0
      tauri/src/endpoints/cmd.rs

+ 3 - 0
tauri/src/endpoints.rs

@@ -20,6 +20,9 @@ pub(crate) fn handle<T: 'static>(webview: &mut WebView<'_, T>, arg: &str) -> cra
             event_init = event_init
           ))?;
         }
+        Reload {} => {
+            webview.eval(include_str!(concat!(env!("TAURI_DIR"), "/tauri.js")));
+        }
         #[cfg(any(feature = "all-api", feature = "readTextFile"))]
         ReadTextFile {
           path,

+ 1 - 0
tauri/src/endpoints/cmd.rs

@@ -4,6 +4,7 @@ use serde::Deserialize;
 #[serde(tag = "cmd", rename_all = "camelCase")]
 pub enum Cmd {
   Init {},
+  Reload {},
   #[cfg(any(feature = "all-api", feature = "readTextFile"))]
   ReadTextFile {
     path: String,