flat_router.rs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. use dioxus_desktop::{tao::dpi::LogicalSize, Config, WindowBuilder};
  4. use dioxus_router::prelude::*;
  5. fn main() {
  6. env_logger::init();
  7. let cfg = Config::new().with_window(
  8. WindowBuilder::new()
  9. .with_title("Spinsense Client")
  10. .with_inner_size(LogicalSize::new(600, 1000))
  11. .with_resizable(false),
  12. );
  13. dioxus_desktop::launch_cfg(app, cfg)
  14. }
  15. fn app(cx: Scope) -> Element {
  16. use_router(cx, &|| RouterConfiguration::default(), &|| {
  17. Segment::content(comp(Home))
  18. .fixed("games", comp(Games))
  19. .fixed("play", comp(Play))
  20. .fixed("settings", comp(Settings))
  21. });
  22. render! {
  23. Outlet { }
  24. p {
  25. "----"
  26. }
  27. nav {
  28. ul {
  29. li { Link { target: "/", "Home" } }
  30. li { Link { target: "/games", "Games" } }
  31. li { Link { target: "/play", "Play" } }
  32. li { Link { target: "/settings", "Settings" } }
  33. }
  34. }
  35. }
  36. }
  37. fn Home(cx: Scope) -> Element {
  38. render!("Home")
  39. }
  40. fn Games(cx: Scope) -> Element {
  41. render!("Games")
  42. }
  43. fn Play(cx: Scope) -> Element {
  44. render!("Play")
  45. }
  46. fn Settings(cx: Scope) -> Element {
  47. render!("Settings")
  48. }