Fix web redirect routes (#4109)

This commit is contained in:
Evan Almloff authored and GitHub committed 2025-05-14 08:42:23 +02:00
1 parent d948ac23af
commit 53ef78823d
8 files changed
+131 -2

No files matched your search

@@ -0,0 +1,57 @@
use dioxus::prelude::*;
fn main() {
launch(|| {
rsx! {
Router::<Route> {}
}
})
}
#[derive(Routable, Clone, PartialEq)]
#[rustfmt::skip]
enum Route {
#[redirect("/",|| Route::Other)]
#[route("/other")]
Other,
#[route("/other/:id")]
OtherId { id: String },
#[route("/:..segments")]
NotFound { segments: Vec<String> },
}
#[component]
fn Other() -> Element {
rsx! {
div {
id: "other",
"Other"
}
Link {
id: "other-id-link",
to: Route::OtherId { id: "123".to_string() },
"go to OtherId"
}
}
}
#[component]
fn OtherId(id: String) -> Element {
rsx! {
div {
id: "other-id",
"OtherId {id}"
}
}
}
#[component]
fn NotFound(segments: Vec<String>) -> Element {
rsx! {
div {
id: "not-found",
"NotFound {segments:?}"
}
}
}