import { useEffect, useState } from 'react'; import styles from './index.module.css'; import TopTabs from './TopTabs'; import { useLocation } from 'react-router-dom'; import ScrollReveal from '@/components/ScrollReveal'; type Data = { tabItems: { icon?: string; tabName?: string; contentTitle?: string; contentSubtitle?: string; contentText?: string; content?: string; /** 以 mockData 为准 */ sideImage?: string; path?: string; items?: {label: string}[]; }[] backgroundImage?: string; titleDirection?: 'row' | 'column'; } export default function TopTabsSection({ data, className }: { data: Data, className?: string }) { const location = useLocation(); const hash = location.hash; const hashId = decodeURIComponent(hash.replace('#', '')); const [activeIndex, setActiveIndex] = useState(0); useEffect(() => { if (hashId && data.tabItems) { const index = data.tabItems.findIndex((item) => item.tabName === hashId); if (index !== -1) { setActiveIndex(index); } } }, [hashId, data.tabItems]) return (
) }