1
0

flat_router.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. use dioxus::prelude::*;
  2. use dioxus_desktop::{tao::dpi::LogicalSize, Config, WindowBuilder};
  3. use dioxus_router::{Link, Route, Router};
  4. fn main() {
  5. env_logger::init();
  6. let cfg = Config::new().with_window(
  7. WindowBuilder::new()
  8. .with_inner_size(LogicalSize::new(600, 1000))
  9. .with_resizable(false),
  10. );
  11. dioxus_desktop::launch_cfg(app, cfg)
  12. }
  13. fn app(cx: Scope) -> Element {
  14. cx.render(rsx! {
  15. div {
  16. Router {
  17. Route { to: "/", "Home" }
  18. Route { to: "/games", "Games" }
  19. Route { to: "/play", "Play" }
  20. Route { to: "/settings", "Settings" }
  21. p { "----" }
  22. nav {
  23. ul {
  24. Link { to: "/", li { "Home" } }
  25. Link { to: "/games", li { "Games" } }
  26. Link { to: "/play", li { "Play" } }
  27. Link { to: "/settings", li { "Settings" } }
  28. }
  29. }
  30. }
  31. }
  32. })
  33. }