fix: missing asset protocol path (#2484)

This commit is contained in:
Ngo Iok Ui (Wu Yu Wei)
2021-08-23 03:12:45 +08:00
committed by GitHub
parent 0391ac3dc9
commit 994b5325dd
4 changed files with 12 additions and 2 deletions

7
.changes/asset-path.md Normal file
View File

@@ -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`.

File diff suppressed because one or more lines are too long

View File

@@ -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()

View File

@@ -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}`
}