wip: docs, html! macro, more
This commit is contained in:
1 parent
8f0bb5dc5b
commit
caf772cf24
27 files changed
+407
-191
No files matched your search
@@ -8,7 +8,7 @@ Dioxus-webview is an attempt at making a simpler "Tauri" where creating desktop
|
||||
// main.rs
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
dioxus_webview::new(|cx| {
|
||||
dioxus_desktop::new(|cx| {
|
||||
let (count, set_count) = use_state(cx, || 0);
|
||||
cx.render(html! {
|
||||
<div>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "webview-client"
|
||||
version = "0.1.0"
|
||||
authors = ["Jonathan Kelley <jkelleyrtp@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dioxus-core = {path = "../../core"}
|
||||
@@ -1,64 +0,0 @@
|
||||
use dioxus_core::patch::Edit;
|
||||
use dioxus_core::prelude::*;
|
||||
|
||||
static SERVER_RENDERED_KEY: &'static str = "abc123";
|
||||
#[derive(Debug, PartialEq, Props)]
|
||||
struct ServerRendered {
|
||||
name0: String,
|
||||
name1: String,
|
||||
name2: String,
|
||||
name3: String,
|
||||
name4: String,
|
||||
name5: String,
|
||||
name6: String,
|
||||
name7: String,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[cfg(old)]
|
||||
fn blah() {
|
||||
// connect to the host server
|
||||
|
||||
let server_rendered = use_server_rendered((111111, 11111, 11), SERVER_RENDERED_KEY, || {
|
||||
ServerRendered {
|
||||
name0: "abc".to_string(),
|
||||
name1: "abc".to_string(),
|
||||
name2: "abc".to_string(),
|
||||
name3: "abc".to_string(),
|
||||
name4: "abc".to_string(),
|
||||
name5: "abc".to_string(),
|
||||
name6: "abc".to_string(),
|
||||
name7: "abc".to_string(),
|
||||
}
|
||||
});
|
||||
|
||||
let handler = dioxus_liveview::new_handler()
|
||||
.from_directory("abc123") // serve a given directory as the root
|
||||
.with_context(|| SomeContext {}) // build out a new context for all of the server-rendered components to share
|
||||
.with_route(SERVER_RENDERED_KEY, |cx: &ServerRendered| {
|
||||
//
|
||||
})
|
||||
.with_route(SERVER_RENDERED_KEY, |cx| {
|
||||
//
|
||||
})
|
||||
.with_route(SERVER_RENDERED_KEY, |cx| {
|
||||
//
|
||||
})
|
||||
.with_route(SERVER_RENDERED_KEY, |cx| {
|
||||
//
|
||||
})
|
||||
.with_route(SERVER_RENDERED_KEY, |cx| {
|
||||
//
|
||||
})
|
||||
.with_route(SERVER_RENDERED_KEY, |cx| {
|
||||
//
|
||||
})
|
||||
// depend on the framework, build a different type of handler
|
||||
// there are instructions on how to integrate this the various rusty web frameworks in the guide
|
||||
.build();
|
||||
|
||||
server.get("abc", handler);
|
||||
}
|
||||
|
||||
fn use_server_rendered<F: Properties>(_p: impl PartialEq, name: &'static str, f: impl Fn() -> F) {}
|
||||
@@ -2,7 +2,7 @@ use dioxus_core as dioxus;
|
||||
use dioxus_core::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus_webview::launch(App, |f| f.with_maximized(true)).expect("Failed");
|
||||
dioxus_desktop::launch(App, |f| f.with_maximized(true)).expect("Failed");
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
|
||||
@@ -128,12 +128,9 @@
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
<div id="_dioxusroot">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
@@ -41,10 +41,7 @@ pub struct WebviewRenderer<T> {
|
||||
root: FC<T>,
|
||||
}
|
||||
enum RpcEvent<'a> {
|
||||
Initialize {
|
||||
//
|
||||
edits: Vec<DomEdit<'a>>,
|
||||
},
|
||||
Initialize { edits: Vec<DomEdit<'a>> },
|
||||
}
|
||||
|
||||
impl<T: Properties + 'static> WebviewRenderer<T> {
|
||||
@@ -129,7 +126,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
||||
.build()?;
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
*control_flow = ControlFlow::Wait;
|
||||
|
||||
match event {
|
||||
Event::WindowEvent {
|
||||
|
||||
Reference in new issue
Block a user