MCPcopy
hub / github.com/chinesehuazhou/python-weekly / HeroSection

Function HeroSection

landing-page/components/HeroSection.tsx:37–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37function HeroSection() {
38 const t = useTranslations();
39
40 // 从stats.json文件读取统计数据
41 const [statsData, setStatsData] = useState({
42 total_issues: 104,
43 total_articles: 1261,
44 total_projects: 1182,
45 total_audio_video: 117,
46 total_hot_topics: 51,
47 total_books: 98
48 });
49
50 useEffect(() => {
51 // 尝试从stats.json文件加载统计数据
52 fetch('/stats.json')
53 .then(response => response.json())
54 .then(data => setStatsData(data))
55 .catch(error => {
56 console.log('Using default stats data:', error);
57 // 如果加载失败,使用默认值
58 });
59 }, []);
60
61 const stats = [
62 {
63 icon: HiDocumentText,
64 value: statsData.total_issues,
65 label: t('hero.stats.issues'),
66 },
67 {
68 icon: HiBookOpen,
69 value: statsData.total_articles,
70 label: t('hero.stats.articles'),
71 },
72 {
73 icon: HiCode,
74 value: statsData.total_projects,
75 label: t('hero.stats.projects'),
76 },
77 ];
78
79 const additionalStats = [
80 {
81 value: statsData.total_audio_video,
82 label: t('hero.stats.audioVideo'),
83 },
84 {
85 value: statsData.total_hot_topics,
86 label: t('hero.stats.hotTopics'),
87 },
88 {
89 value: statsData.total_books,
90 label: t('hero.stats.books'),
91 },
92 ];
93
94 // 为主要统计数据创建动画计数器

Callers

nothing calls this directly

Calls 1

useAnimatedCounterFunction · 0.85

Tested by

no test coverage detected