feat(demo): remove regex

This commit is contained in:
luoxiao 2023-10-11 21:12:45 +08:00
parent 63007dc7c4
commit 17f909d861
2 changed files with 8 additions and 15 deletions

View file

@ -13,7 +13,6 @@ icondata = { version = "0.0.7", features = [
"AiCheckOutlined", "AiCheckOutlined",
] } ] }
leptos_router = { version = "0.5.1", features = ["csr"] } leptos_router = { version = "0.5.1", features = ["csr"] }
regex = "1.8.2"
leptos_devtools = "0.0.1" leptos_devtools = "0.0.1"
prisms = { git = "https://github.com/luoxiaozero/prisms" } prisms = { git = "https://github.com/luoxiaozero/prisms" }

View file

@ -2,25 +2,19 @@ use crate::components::SiteHeader;
use leptos::*; use leptos::*;
use leptos_router::{use_location, use_navigate, Outlet}; use leptos_router::{use_location, use_navigate, Outlet};
use melt_ui::*; use melt_ui::*;
use regex::Regex;
#[component] #[component]
pub fn ComponentsPage() -> impl IntoView { pub fn ComponentsPage() -> impl IntoView {
let loaction = use_location();
let navigate = use_navigate(); let navigate = use_navigate();
let selected = create_rw_signal(String::from("")); let selected = create_rw_signal({
create_effect(move |_| { let loaction = use_location();
let pathname = loaction.pathname.get(); let mut pathname = loaction.pathname.get_untracked();
let re = Regex::new(r"^/melt-ui/components/(.+)$").unwrap(); if pathname.starts_with("/melt-ui/components/") {
let Some(caps) = re.captures(&pathname) else { pathname.drain(20..).collect()
return; } else {
}; String::new()
let Some(path) = caps.get(1) else { }
return;
};
let path = path.as_str().to_string();
selected.set(path);
}); });
create_effect(move |value| { create_effect(move |value| {