Sfoglia il codice sorgente

start migrating desktop to sledgehammer

Evan Almloff 1 anno fa
parent
commit
3063d83406

+ 1 - 1
packages/desktop/Cargo.toml

@@ -12,7 +12,7 @@ keywords = ["dom", "ui", "gui", "react"]
 [dependencies]
 dioxus-core = { workspace = true, features = ["serialize"] }
 dioxus-html = { workspace = true, features = ["serialize", "native-bind"] }
-dioxus-interpreter-js = { workspace = true }
+dioxus-interpreter-js = { workspace = true, features = ["sledgehammer"]}
 dioxus-hot-reload = { workspace = true, optional = true }
 
 serde = "1.0.136"

+ 0 - 1
packages/desktop/src/desktop_context.rs

@@ -14,7 +14,6 @@ use dioxus_core::ScopeState;
 use dioxus_core::VirtualDom;
 #[cfg(all(feature = "hot-reload", debug_assertions))]
 use dioxus_hot_reload::HotReloadMsg;
-use dioxus_interpreter_js::Channel;
 use slab::Slab;
 use wry::application::accelerator::Accelerator;
 use wry::application::event::Event;

+ 2 - 1
packages/desktop/src/protocol.rs

@@ -53,10 +53,11 @@ fn module_loader(root_name: &str) -> String {
 
 pub(super) fn desktop_handler(
     request: &Request<Vec<u8>>,
+    responder: wry::http::response::Responder,
     custom_head: Option<String>,
     custom_index: Option<String>,
     root_name: &str,
-) -> Result<Response<Cow<'static, [u8]>>> {
+) {
     // If the request is for the root, we'll serve the index.html file.
     if request.uri().path() == "/" {
         // If a custom index is provided, just defer to that, expecting the user to know what they're doing.

+ 8 - 2
packages/desktop/src/webview.rs

@@ -44,8 +44,14 @@ 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_asynchronous_custom_protocol("dioxus".into(), move |r, responder| {
+            protocol::desktop_handler(
+                r,
+                responder,
+                custom_head.clone(),
+                index_file.clone(),
+                &root_name,
+            )
         })
         .with_file_drop_handler(move |window, evet| {
             file_handler