Feat: add webview example
This commit is contained in:
1 parent
7730fd4a8c
commit
65d0d611ea
11 files changed
+84
-38
No files matched your search
+3
-2
@@ -24,13 +24,14 @@ tide = { version = "0.15.0" }
|
||||
pulldown-cmark = { version = "0.8.0", default-features = false }
|
||||
|
||||
dioxus-webview = { path = "../packages/webview", version = "0.0.0" }
|
||||
dioxus-hooks = { path = "../packages/hooks", version = "0.0.0" }
|
||||
|
||||
[lib]
|
||||
path = "common.rs"
|
||||
|
||||
[[example]]
|
||||
path = "hello.rs"
|
||||
name = "hello"
|
||||
path = "hello_web.rs"
|
||||
name = "hello_web"
|
||||
|
||||
[[example]]
|
||||
path = "tide_ssr.rs"
|
||||
|
||||
File renamed without changes.
+18
-12
@@ -1,23 +1,29 @@
|
||||
//! Example: Webview Renderer
|
||||
//!
|
||||
//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
|
||||
//!
|
||||
//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
|
||||
//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
|
||||
//! into the native VDom instance.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let app = dioxus_webview::new::<()>(|ctx| {
|
||||
let app = dioxus_webview::new(|ctx| {
|
||||
let (count, set_count) = use_state(ctx, || 0);
|
||||
|
||||
html! {
|
||||
<div>
|
||||
<h1> "Dioxus Desktop Demo" </h1>
|
||||
<p> "Count is {count}"</p>
|
||||
<button onclick=|_| set_count(count + 1) >
|
||||
"Click to increment"
|
||||
</button>
|
||||
<div>
|
||||
<h1> "Dioxus Desktop Demo" </h1>
|
||||
<p> "Count is {count}"</p>
|
||||
<p> "Count is {count}"</p>
|
||||
<p> "Data is {data}"</p>
|
||||
<button onclick=|_| set_count(count + 1) >
|
||||
"Click to increment"
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
app.launch(());
|
||||
}
|
||||
|
||||
fn use_state<T, G>(ctx: &mut Context<G>, init: impl Fn() -> T) -> (T, impl Fn(T)) {
|
||||
let g = init();
|
||||
(g, |_| {})
|
||||
}
|
||||
Reference in new issue
Block a user