|
@@ -13,6 +13,17 @@ use super::{
|
|
HistoryProvider,
|
|
HistoryProvider,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+#[allow(dead_code)]
|
|
|
|
+fn base_path() -> Option<&'static str> {
|
|
|
|
+ dioxus_cli_config::CURRENT_CONFIG.as_ref().ok().and_then(|c| {
|
|
|
|
+ c.dioxus_config
|
|
|
|
+ .web
|
|
|
|
+ .app
|
|
|
|
+ .base_path
|
|
|
|
+ .as_deref()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
#[cfg(not(feature = "serde"))]
|
|
#[cfg(not(feature = "serde"))]
|
|
#[allow(clippy::extra_unused_type_parameters)]
|
|
#[allow(clippy::extra_unused_type_parameters)]
|
|
fn update_scroll<R>(window: &Window, history: &History) {
|
|
fn update_scroll<R>(window: &Window, history: &History) {
|
|
@@ -165,7 +176,7 @@ impl<R: Routable> WebHistory<R> {
|
|
history,
|
|
history,
|
|
listener_navigation: None,
|
|
listener_navigation: None,
|
|
listener_animation_frame: Default::default(),
|
|
listener_animation_frame: Default::default(),
|
|
- prefix,
|
|
|
|
|
|
+ prefix: prefix.or_else(||base_path().map(|s| s.to_string())),
|
|
window,
|
|
window,
|
|
phantom: Default::default(),
|
|
phantom: Default::default(),
|
|
}
|
|
}
|
|
@@ -198,6 +209,16 @@ where
|
|
let location = self.window.location();
|
|
let location = self.window.location();
|
|
let path = location.pathname().unwrap_or_else(|_| "/".into())
|
|
let path = location.pathname().unwrap_or_else(|_| "/".into())
|
|
+ &location.search().unwrap_or("".into());
|
|
+ &location.search().unwrap_or("".into());
|
|
|
|
+ let path = match self.prefix {
|
|
|
|
+ None => path,
|
|
|
|
+ Some(ref prefix) => {
|
|
|
|
+ if path.starts_with(prefix) {
|
|
|
|
+ path[prefix.len()..].to_string()
|
|
|
|
+ } else {
|
|
|
|
+ path
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
R::from_str(&path).unwrap_or_else(|err| panic!("{}", err))
|
|
R::from_str(&path).unwrap_or_else(|err| panic!("{}", err))
|
|
}
|
|
}
|
|
|
|
|