import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { api } from '../api/client'; import type { ModelListItem } from '../types'; import { computeSpeedEvolution, ERAS, pickRepresentatives, } from '../lib/eras'; import { Thumb } from '../components/Thumb'; import { CategoryIcon, IconForward } from '../components/icons'; import { fmtEra, fmtValueUnit } from '../lib/format'; import { EvolutionCurve } from '../components/EvolutionCurve'; export function HomePage() { const [models, setModels] = useState([]); useEffect(() => { api.models({ pageSize: 1000 }).then((d) => setModels(d.items)).catch(() => {}); }, []); const evo = computeSpeedEvolution(models); const total = models.length; const years = models .map((m) => m.first_year) .filter((y): y is number => typeof y === 'number'); const minYear = years.length ? Math.min(...years) : 1881; const topSpeed = Math.max(0, ...models.map((m) => m.max_speed_value ?? 0)); return (
{/* 英雄区 + 时速演进:并排一行 */}

一部跑在铁轨上的中国工业史

从蒸汽的轰鸣到复兴号的风驰,跟随这条主线,看中国机车如何 引进、消化、再到自主领跑

{total || '—'} 收录车型
{minYear} 起始年代
{topSpeed || '—'} 最高时速 km/h
4 技术时代
进入图鉴探索

时速的跃迁

一条曲线读懂百年提速:从蒸汽机车的数十公里,到高铁的数百公里。

{evo.length >= 2 && }
{/* 主线:四个时代章节 */}

沿着时间的铁轨

{ERAS.map((era, i) => { const reps = pickRepresentatives(models, era, 4); return (

{i + 1} {era.title}

{era.period}

{era.blurb}

{reps.map((m) => ( {m.cover_url ? ( {m.model_code} ) : ( )} {m.model_code} {fmtValueUnit(m.max_speed_value, m.max_speed_unit)} ·{' '} {fmtEra(m.first_year, m.last_year)} ))}
探索全部{era.title.replace('时代', '')}车型
); })}
); }