import Banner from "@/components/Banner"; import YearPicker from "@/components/YearPicker"; import styles from "./History.module.css"; import { useState, useRef, useLayoutEffect } from "react"; type TimelineItem = { year: number; description: string }; const TIMELINE_DATA: TimelineItem[] = [ { year: 2025, description: "银泰集团持续深化战略布局,推动高质量发展。" }, { year: 2024, description: "银泰集团创新发展模式,拓展业务新领域。" }, { year: 2023, description: "银泰集团核心业务稳健增长,品牌影响力持续提升。" }, { year: 2022, description: "银泰集团深化数字化转型,提升运营效率。" }, { year: 2018, description: "银泰集团推进战略转型升级,开启新篇章。" }, { year: 2016, description: "银泰集团拓展多元化业务,夯实发展基础。" }, { year: 2015, description: "银泰集团完善产业布局,增强核心竞争力。" }, { year: 2014, description: "银泰集团加速全国化扩张,品牌影响力扩大。" }, { year: 2013, description: "银泰集团稳健发展,主营业务持续向好。" }, { year: 2010, description: "银泰集团抓住市场机遇,实现跨越式发展。" }, { year: 2009, description: "银泰集团应对金融危机,保持稳健经营。" }, { year: 2008, description: "银泰集团完善管理体系,提升运营水平。" }, { year: 2007, description: "银泰集团上市,开启资本化发展新征程。" }, { year: 1998, description: "银泰集团快速成长,确立行业领先地位。" }, { year: 1997, description: "银泰集团成立,迈出创业第一步。" }, ]; export default function AboutHistory() { const [year, setYear] = useState(null); const handleYearChange = (year: number | null) => { setYear(year); // 滚动到对应的年份 const yearEl = document.querySelector(`#year-${year}`); if (yearEl) { yearEl.scrollIntoView({ behavior: "smooth" }); } }; return (
); } type HistoryTimelineProps = { data: TimelineItem[]; selectedYear: number | null; onYearChange: (year: number | null) => void; }; function TimelineItemRow({ item, index, isSelected, onMouseEnter, }: { item: TimelineItem; index: number; isSelected: boolean; onMouseEnter: () => void; }) { const isRight = index % 2 === 0; const contentSideRef = useRef(null); const dotLineRef = useRef(null); useLayoutEffect(() => { const contentEl = contentSideRef.current; if (!contentEl) return; const updateHeight = () => { if (!contentSideRef.current || !dotLineRef.current || !isSelected) return; dotLineRef.current.style.height = `${contentSideRef.current.offsetHeight}px`; }; updateHeight(); const observer = new ResizeObserver(updateHeight); observer.observe(contentEl); return () => observer.disconnect(); }, [isSelected]); return (
{!isRight && (
{item.year}

{item.description}

)}
{isSelected &&
}
{isRight && (
{item.year}

{item.description}

)}
); } function HistoryTimeline({ data, selectedYear, onYearChange }: HistoryTimelineProps) { return (
{data.map((item, index) => ( onYearChange(item.year)} /> ))}
); }