From 3ac5a694dfd37061f0c05ae4ea64f76e33a93ad6 Mon Sep 17 00:00:00 2001 From: Ember <197652334@qq.com> Date: Wed, 5 Nov 2025 13:58:34 +0800 Subject: [PATCH] refactor: extract repeated star formatting logic - Extract formattedStars calculation to avoid duplication - Keep tabular-nums span for consistent number width during animation - Address code review feedback from @xqliu Co-Authored-By: tinkle-community --- web/src/components/landing/HeroSection.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/src/components/landing/HeroSection.tsx b/web/src/components/landing/HeroSection.tsx index ecc93f0a..fda8ff8c 100644 --- a/web/src/components/landing/HeroSection.tsx +++ b/web/src/components/landing/HeroSection.tsx @@ -22,6 +22,9 @@ export default function HeroSection({ language }: HeroSectionProps) { duration: 2000, }) + // 格式化 stars 显示 + const formattedStars = (animatedStars / 1000).toFixed(1) + const fadeInUp = { initial: { opacity: 0, y: 60 }, animate: { opacity: 1, y: 0 }, @@ -48,12 +51,12 @@ export default function HeroSection({ language }: HeroSectionProps) { ) : language === 'zh' ? ( <> {daysOld} 天内{' '} - {(animatedStars / 1000).toFixed(1)} + {formattedStars} K+ GitHub Stars ) : ( <> - {(animatedStars / 1000).toFixed(1)} + {formattedStars} K+ GitHub Stars in {daysOld} days )}