import { useState, useEffect, useCallback } from 'react'; import { HashRouter, NavLink, useNavigate } from 'react-router-dom'; import Router from './Router'; import { links } from '../routes'; import { GitHubLogoIcon, LogoIcon } from '../assets/icons'; import './Index.css'; function DemoExplorerContent({ productTag, publicName, skins, Globals, Button, Segmented, }) { const navigate = useNavigate(); const [skin, setSkin] = useState(skins[0].id); const [title, setTitle] = useState(''); const [githubLink, setGithubLink] = useState(''); const [show, setShow] = useState(false); const baseLink = 'https://github.com/svar-widgets/react-' + productTag + '/tree/main/demos/cases/'; useEffect(() => { document.body.className = `wx-willow-theme`; }, []); const handleRouteChange = useCallback( (path) => { const parts = path.split('/'); const page = parts[1]; const newSkin = parts[2]; if (newSkin && newSkin !== skin) { setSkin(newSkin); } const targetPage = `/${page}/:skin`; const matched = links.find((a) => a[0] === targetPage); if (matched) { setTitle(matched[1]); const name = matched[3] || matched[1]; setGithubLink(`${baseLink}${name}.jsx`); } }, [skin], ); const handleSkinChange = ({ value }) => { setSkin(value); const currentPath = window.location.hash.slice(1); const parts = currentPath.split('/'); if (parts[1]) { navigate(`/${parts[1]}/${value}`); } }; const toggleSidebar = () => { setShow(!show); }; return (