add web history integration

This commit is contained in:
Adrian Wannenmacher committed 2022-12-15 14:46:40 +01:00
1 parent e26e44fbc5
commit 53d97755fd
6 files changed
+144 -4

No files matched your search

+8 -3
View File
@@ -20,13 +20,18 @@ futures-util = "0.3.25"
log = "0.4.17"
thiserror = "1.0.37"
# for wasm
[features]
regex = ["dioxus-router-core/regex"]
serde = ["dioxus-router-core/serde"]
web = ["dioxus-router-core/web"]
[dev-dependencies]
dioxus = { path = "../dioxus" }
dioxus-desktop = { path = "../desktop" }
dioxus-ssr = { path = "../ssr" }
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
dioxus-desktop = { path = "../desktop" }
[target.'cfg(target_family = "wasm")'.dev-dependencies]
dioxus-router = { path = ".", features = ["web"] }
dioxus-web = { path= "../web" }
+3
View File
@@ -4,7 +4,10 @@ use dioxus::prelude::*;
use dioxus_router::prelude::*;
fn main() {
#[cfg(not(feature = "web"))]
dioxus_desktop::launch(App);
#[cfg(feature = "web")]
dioxus_web::launch(App);
}
fn App(cx: Scope) -> Element {
+6 -1
View File
@@ -188,11 +188,16 @@ pub struct RouterConfiguration {
impl Default for RouterConfiguration {
fn default() -> Self {
#[cfg(not(feature = "web"))]
let history = Box::<MemoryHistory>::default();
#[cfg(feature = "web")]
let history = Box::<crate::history::WebHistory>::default();
Self {
failure_external_navigation: comp(FailureExternalNavigation),
failure_named_navigation: comp(FailureNamedNavigation),
failure_redirection_limit: comp(FailureRedirectionLimit),
history: Box::<MemoryHistory>::default(),
history: history,
on_update: None,
synchronous: false,
}