fix desktop renderer on windows
This commit is contained in:
1 parent
33f0f0c172
commit
b14aaca7b2
2 files changed
+23
-10
No files matched your search
@@ -2,6 +2,17 @@ use dioxus_interpreter_js::binary_protocol::SLEDGEHAMMER_JS;
|
|||||||
|
|
||||||
use std::io::Write;
|
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() {
|
fn main() {
|
||||||
let prevent_file_upload = r#"// Prevent file inputs from opening the file dialog on click
|
let prevent_file_upload = r#"// Prevent file inputs from opening the file dialog on click
|
||||||
let inputs = document.querySelectorAll("input");
|
let inputs = document.querySelectorAll("input");
|
||||||
@@ -26,21 +37,23 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"#;
|
}"#;
|
||||||
let polling_request = r#"// Poll for requests
|
let polling_request = format!(
|
||||||
window.interpreter.wait_for_request = () => {
|
r#"// Poll for requests
|
||||||
fetch(new Request("dioxus://index.html/edits"))
|
window.interpreter.wait_for_request = () => {{
|
||||||
.then(response => {
|
fetch(new Request("{EDITS_PATH}"))
|
||||||
|
.then(response => {{
|
||||||
response.arrayBuffer()
|
response.arrayBuffer()
|
||||||
.then(bytes => {
|
.then(bytes => {{
|
||||||
run_from_bytes(bytes);
|
run_from_bytes(bytes);
|
||||||
window.interpreter.wait_for_request();
|
window.interpreter.wait_for_request();
|
||||||
});
|
}});
|
||||||
})
|
}})
|
||||||
}"#;
|
}}"#
|
||||||
|
);
|
||||||
let mut interpreter = SLEDGEHAMMER_JS
|
let mut interpreter = SLEDGEHAMMER_JS
|
||||||
.replace("/*POST_HANDLE_EDITS*/", prevent_file_upload)
|
.replace("/*POST_HANDLE_EDITS*/", prevent_file_upload)
|
||||||
.replace("export", "")
|
.replace("export", "")
|
||||||
+ polling_request;
|
+ &polling_request;
|
||||||
while let Some(import_start) = interpreter.find("import") {
|
while let Some(import_start) = interpreter.find("import") {
|
||||||
let import_end = interpreter[import_start..]
|
let import_end = interpreter[import_start..]
|
||||||
.find(|c| c == ';' || c == '\n')
|
.find(|c| c == ';' || c == '\n')
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pub use wry::application as tao;
|
|||||||
use wry::application::window::Window;
|
use wry::application::window::Window;
|
||||||
use wry::webview::{WebContext, WebView, WebViewBuilder};
|
use wry::webview::{WebContext, WebView, WebViewBuilder};
|
||||||
|
|
||||||
pub fn build(
|
pub(crate) fn build(
|
||||||
cfg: &mut Config,
|
cfg: &mut Config,
|
||||||
event_loop: &EventLoopWindowTarget<UserWindowEvent>,
|
event_loop: &EventLoopWindowTarget<UserWindowEvent>,
|
||||||
proxy: EventLoopProxy<UserWindowEvent>,
|
proxy: EventLoopProxy<UserWindowEvent>,
|
||||||
|
|||||||
Reference in new issue
Block a user