mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-03 07:23:27 +00:00
fix desktop renderer on windows
This commit is contained in:
parent
33f0f0c172
commit
b14aaca7b2
2 changed files with 23 additions and 10 deletions
|
@ -2,6 +2,17 @@ use dioxus_interpreter_js::binary_protocol::SLEDGEHAMMER_JS;
|
|||
|
||||
use std::io::Write;
|
||||
|
||||
const EDITS_PATH: &str = {
|
||||
#[cfg(any(target_os = "android", target_os = "windows"))]
|
||||
{
|
||||
"http://dioxus.index.html/edits"
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "windows")))]
|
||||
{
|
||||
"dioxus://index.html/edits"
|
||||
}
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let prevent_file_upload = r#"// Prevent file inputs from opening the file dialog on click
|
||||
let inputs = document.querySelectorAll("input");
|
||||
|
@ -26,21 +37,23 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}"#;
|
||||
let polling_request = r#"// Poll for requests
|
||||
window.interpreter.wait_for_request = () => {
|
||||
fetch(new Request("dioxus://index.html/edits"))
|
||||
.then(response => {
|
||||
let polling_request = format!(
|
||||
r#"// Poll for requests
|
||||
window.interpreter.wait_for_request = () => {{
|
||||
fetch(new Request("{EDITS_PATH}"))
|
||||
.then(response => {{
|
||||
response.arrayBuffer()
|
||||
.then(bytes => {
|
||||
.then(bytes => {{
|
||||
run_from_bytes(bytes);
|
||||
window.interpreter.wait_for_request();
|
||||
});
|
||||
})
|
||||
}"#;
|
||||
}});
|
||||
}})
|
||||
}}"#
|
||||
);
|
||||
let mut interpreter = SLEDGEHAMMER_JS
|
||||
.replace("/*POST_HANDLE_EDITS*/", prevent_file_upload)
|
||||
.replace("export", "")
|
||||
+ polling_request;
|
||||
+ &polling_request;
|
||||
while let Some(import_start) = interpreter.find("import") {
|
||||
let import_end = interpreter[import_start..]
|
||||
.find(|c| c == ';' || c == '\n')
|
||||
|
|
|
@ -7,7 +7,7 @@ pub use wry::application as tao;
|
|||
use wry::application::window::Window;
|
||||
use wry::webview::{WebContext, WebView, WebViewBuilder};
|
||||
|
||||
pub fn build(
|
||||
pub(crate) fn build(
|
||||
cfg: &mut Config,
|
||||
event_loop: &EventLoopWindowTarget<UserWindowEvent>,
|
||||
proxy: EventLoopProxy<UserWindowEvent>,
|
||||
|
|
Loading…
Reference in a new issue