Merge pull request #203 from DioxusLabs/jk/local-router
Feat: abstract the router on a per-platform basis and add docs
This commit is contained in:
33 files changed
+854
-552
No files matched your search
@@ -1,7 +1,6 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use fermi::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::desktop::launch(app)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use dioxus::router::*;
|
||||
|
||||
use dioxus::desktop::tao::dpi::LogicalSize;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
dioxus::desktop::launch_cfg(app, |c| {
|
||||
c.with_window(|c| {
|
||||
c.with_title("Spinsense Client")
|
||||
.with_inner_size(LogicalSize::new(600, 1000))
|
||||
.with_resizable(false)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
Router {
|
||||
Route { to: "/", "Home" }
|
||||
Route { to: "/games", "Games" }
|
||||
Route { to: "/play", "Play" }
|
||||
Route { to: "/settings", "Settings" }
|
||||
|
||||
p {
|
||||
"----"
|
||||
}
|
||||
nav {
|
||||
ul {
|
||||
Link { to: "/", li { "Home" } }
|
||||
Link { to: "/games", li { "Games" } }
|
||||
Link { to: "/play", li { "Play" } }
|
||||
Link { to: "/settings", li { "Settings" } }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
+3
-2
@@ -31,7 +31,7 @@ fn app(cx: Scope) -> Element {
|
||||
}
|
||||
|
||||
fn BlogPost(cx: Scope) -> Element {
|
||||
let post = dioxus::router::use_route(&cx).last_segment();
|
||||
let post = dioxus::router::use_route(&cx).last_segment()?;
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
@@ -47,7 +47,8 @@ struct Query {
|
||||
}
|
||||
|
||||
fn User(cx: Scope) -> Element {
|
||||
let post = dioxus::router::use_route(&cx).last_segment();
|
||||
let post = dioxus::router::use_route(&cx).last_segment()?;
|
||||
|
||||
let query = dioxus::router::use_route(&cx)
|
||||
.query::<Query>()
|
||||
.unwrap_or(Query { bold: false });
|
||||
|
||||
Reference in new issue
Block a user