Преглед на файлове

fix: missing asset protocol path (#2484)

Ngo Iok Ui (Wu Yu Wei) преди 4 години
родител
ревизия
994b5325dd
променени са 4 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. 7 0
      .changes/asset-path.md
  2. 0 0
      core/tauri/scripts/bundle.js
  3. 3 0
      core/tauri/src/manager.rs
  4. 1 1
      tooling/api/src/tauri.ts

+ 7 - 0
.changes/asset-path.md

@@ -0,0 +1,7 @@
+---
+"api": patch
+"tauri": patch
+---
+
+Fix missing asset protocol path.Now the protocol is `https://asset.localhost/path/to/file` on Windows. Lunix and macOS
+is still `asset://path/to/file`.

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
core/tauri/scripts/bundle.js


+ 3 - 0
core/tauri/src/manager.rs

@@ -284,6 +284,9 @@ impl<R: Runtime> WindowManager<R> {
     }
     if !webview_attributes.has_uri_scheme_protocol("asset") {
       webview_attributes = webview_attributes.register_uri_scheme_protocol("asset", move |url| {
+        #[cfg(target_os = "windows")]
+        let path = url.replace("asset://localhost/", "");
+        #[cfg(not(target_os = "windows"))]
         let path = url.replace("asset://", "");
         let path = percent_encoding::percent_decode(path.as_bytes())
           .decode_utf8_lossy()

+ 1 - 1
tooling/api/src/tauri.ts

@@ -101,7 +101,7 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
  */
 function convertFileSrc(filePath: string): string {
   return navigator.userAgent.includes('Windows')
-    ? `https://asset.${filePath}`
+    ? `https://asset.localhost/${filePath}`
     : `asset://${filePath}`
 }
 

Някои файлове не бяха показани, защото твърде много файлове са промени