webview.rs 582 B

1234567891011121314151617181920212223
  1. use dioxus::prelude::*;
  2. fn main() {
  3. let app = dioxus_webview::new::<()>(|ctx| {
  4. let (count, set_count) = use_state(ctx, || 0);
  5. html! {
  6. <div>
  7. <h1> "Dioxus Desktop Demo" </h1>
  8. <p> "Count is {count}"</p>
  9. <button onclick=|_| set_count(count + 1) >
  10. "Click to increment"
  11. </button>
  12. </div>
  13. }
  14. });
  15. app.launch(());
  16. }
  17. fn use_state<T, G>(ctx: &mut Context<G>, init: impl Fn() -> T) -> (T, impl Fn(T)) {
  18. let g = init();
  19. (g, |_| {})
  20. }