浏览代码

bump wry to 0.34

Evan Almloff 1 年之前
父节点
当前提交
5fdff4b7ed
共有 4 个文件被更改,包括 33 次插入10 次删除
  1. 1 1
      examples/mobile_demo/Cargo.toml
  2. 2 4
      packages/desktop/Cargo.toml
  3. 29 4
      packages/desktop/src/webview.rs
  4. 1 1
      packages/html/Cargo.toml

+ 1 - 1
examples/mobile_demo/Cargo.toml

@@ -35,7 +35,7 @@ frameworks = ["WebKit"]
 [dependencies]
 anyhow = "1.0.56"
 log = "0.4.11"
-wry = "0.31.0"
+wry = "0.34.0"
 dioxus = { path = "../../packages/dioxus" }
 dioxus-desktop = { path = "../../packages/desktop", features = [
     "tokio_runtime",

+ 2 - 4
packages/desktop/Cargo.toml

@@ -19,7 +19,7 @@ serde = "1.0.136"
 serde_json = "1.0.79"
 thiserror = { workspace = true }
 tracing = { workspace = true }
-wry = { version = "0.31.0", default-features = false, features = ["protocol", "file-drop"] }
+wry = { version = "0.34.0", default-features = false, features = ["tao", "protocol", "file-drop"] }
 futures-channel = { workspace = true }
 tokio = { workspace = true, features = [
     "sync",
@@ -41,7 +41,7 @@ crossbeam-channel = "0.5.8"
 
 
 [target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
-rfd = "0.11.3"
+rfd = "0.12"
 global-hotkey = { git = "https://github.com/tauri-apps/global-hotkey" }
 
 [target.'cfg(target_os = "ios")'.dependencies]
@@ -58,8 +58,6 @@ tokio_runtime = ["tokio"]
 fullscreen = ["wry/fullscreen"]
 transparent = ["wry/transparent"]
 devtools = ["wry/devtools"]
-tray = ["wry/tray"]
-dox = ["wry/dox"]
 hot-reload = ["dioxus-hot-reload"]
 
 [package.metadata.docs.rs]

+ 29 - 4
packages/desktop/src/webview.rs

@@ -5,6 +5,7 @@ use tao::event_loop::{EventLoopProxy, EventLoopWindowTarget};
 pub use wry;
 pub use wry::application as tao;
 use wry::application::window::Window;
+use wry::http::Response;
 use wry::webview::{WebContext, WebView, WebViewBuilder};
 
 pub fn build(
@@ -44,9 +45,24 @@ pub fn build(
                 _ = proxy.send_event(UserWindowEvent(EventData::Ipc(message), window.id()));
             }
         })
-        .with_custom_protocol(String::from("dioxus"), move |r| {
-            protocol::desktop_handler(r, custom_head.clone(), index_file.clone(), &root_name)
-        })
+        .with_custom_protocol(
+            String::from("dioxus"),
+            move |r| match protocol::desktop_handler(
+                &r,
+                custom_head.clone(),
+                index_file.clone(),
+                &root_name,
+            ) {
+                Ok(response) => response,
+                Err(err) => {
+                    tracing::error!("Error: {}", err);
+                    Response::builder()
+                        .status(500)
+                        .body(err.to_string().into_bytes().into())
+                        .unwrap()
+                }
+            },
+        )
         .with_file_drop_handler(move |window, evet| {
             file_handler
                 .as_ref()
@@ -71,7 +87,16 @@ pub fn build(
     // .with_web_context(&mut web_context);
 
     for (name, handler) in cfg.protocols.drain(..) {
-        webview = webview.with_custom_protocol(name, handler)
+        webview = webview.with_custom_protocol(name, move |r| match handler(&r) {
+            Ok(response) => response,
+            Err(err) => {
+                tracing::error!("Error: {}", err);
+                Response::builder()
+                    .status(500)
+                    .body(err.to_string().into_bytes().into())
+                    .unwrap()
+            }
+        })
     }
 
     if cfg.disable_context_menu {

+ 1 - 1
packages/html/Cargo.toml

@@ -21,7 +21,7 @@ keyboard-types = "0.7"
 async-trait = "0.1.58"
 serde-value = "0.7.0"
 tokio = { workspace = true, features = ["fs", "io-util"], optional = true }
-rfd = { version = "0.11.3", optional = true }
+rfd = { version = "0.12", optional = true }
 async-channel = "1.8.0"
 serde_json = { version = "1", optional = true }