Skip to content

Commit 2fa51ec

Browse files
committed
feat(ui): 添加滚动进度条和粒子动画效果
- 实现鼠标跟随的粒子效果和光球动画 - 添加页面滚动进度条组件 - 优化按钮和卡片悬停交互效果
1 parent 824f19f commit 2fa51ec

2 files changed

Lines changed: 368 additions & 100 deletions

File tree

src/pages/index.js

Lines changed: 94 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
55
import Layout from '@theme/Layout';
66
import styles from './index.module.css';
77

8+
// 滚动进度条组件
9+
function ScrollProgress() {
10+
const [scrollProgress, setScrollProgress] = useState(0);
11+
12+
useEffect(() => {
13+
const handleScroll = () => {
14+
const totalHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
15+
const progress = (window.scrollY / totalHeight) * 100;
16+
setScrollProgress(progress);
17+
};
18+
19+
window.addEventListener('scroll', handleScroll);
20+
return () => window.removeEventListener('scroll', handleScroll);
21+
}, []);
22+
23+
return (
24+
<div className={styles.scrollProgress}>
25+
<div
26+
className={styles.scrollProgressBar}
27+
style={{ width: `${scrollProgress}%` }}
28+
></div>
29+
</div>
30+
);
31+
}
32+
833
// 打字机效果 - 更流畅的实现
934
function TypeWriter({ texts, speed = 80 }) {
1035
const [displayText, setDisplayText] = useState('');
@@ -96,6 +121,18 @@ function AnimatedNumber({ end, duration = 2000, suffix = '' }) {
96121

97122
function HomepageHeader() {
98123
const { siteConfig } = useDocusaurusContext();
124+
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
125+
126+
useEffect(() => {
127+
const handleMouseMove = (e) => {
128+
const x = (e.clientX / window.innerWidth - 0.5) * 20;
129+
const y = (e.clientY / window.innerHeight - 0.5) * 20;
130+
setMousePosition({ x, y });
131+
};
132+
133+
window.addEventListener('mousemove', handleMouseMove);
134+
return () => window.removeEventListener('mousemove', handleMouseMove);
135+
}, []);
99136

100137
// 获取最新报告路径 - 基于实际存在的报告
101138
const getLatestReportPath = () => {
@@ -108,9 +145,39 @@ function HomepageHeader() {
108145
<header className={styles.heroBanner}>
109146
<div className={styles.heroBackground}>
110147
<div className={styles.gridLines}></div>
111-
<div className={styles.glowOrb1}></div>
112-
<div className={styles.glowOrb2}></div>
113-
<div className={styles.glowOrb3}></div>
148+
<div
149+
className={styles.glowOrb1}
150+
style={{
151+
transform: `translate(${mousePosition.x}px, ${mousePosition.y}px)`
152+
}}
153+
></div>
154+
<div
155+
className={styles.glowOrb2}
156+
style={{
157+
transform: `translate(${-mousePosition.x * 0.8}px, ${-mousePosition.y * 0.8}px)`
158+
}}
159+
></div>
160+
<div
161+
className={styles.glowOrb3}
162+
style={{
163+
transform: `translate(${mousePosition.x * 0.6}px, ${-mousePosition.y * 0.6}px)`
164+
}}
165+
></div>
166+
{/* 添加粒子效果 */}
167+
<div className={styles.particles}>
168+
{[...Array(20)].map((_, i) => (
169+
<div
170+
key={i}
171+
className={styles.particle}
172+
style={{
173+
left: `${Math.random() * 100}%`,
174+
top: `${Math.random() * 100}%`,
175+
animationDelay: `${Math.random() * 10}s`,
176+
animationDuration: `${15 + Math.random() * 10}s`
177+
}}
178+
></div>
179+
))}
180+
</div>
114181
</div>
115182

116183
<div className={styles.heroContent}>
@@ -213,108 +280,72 @@ function StatsSection() {
213280
function FeaturesSection() {
214281
const features = [
215282
{
216-
icon: '🔍',
217-
title: '智能数据采集',
218-
description: '每日自动爬取 GitHub Trending,获取最新热门项目数据,支持多语言过滤',
219-
gradient: 'linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)',
220-
},
221-
{
222-
icon: '🤖',
223-
title: 'LLM 深度分析',
224-
description: '利用大语言模型对项目进行深度解读,提供技术洞察、趋势预测和学习建议',
225-
gradient: 'linear-gradient(135deg, #f472b6 0%, #fb7185 100%)',
226-
},
227-
{
228-
icon: '📊',
229-
title: '精美可视化',
230-
description: '生成结构化的 Markdown 报告,表格、图表、代码示例一应俱全',
231-
gradient: 'linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%)',
232-
},
233-
{
234-
icon: '⚡',
235-
title: '全自动流水线',
236-
description: '基于 GitHub Actions 实现全流程自动化,每日定时触发,零人工干预',
237-
gradient: 'linear-gradient(135deg, #fb923c 0%, #f97316 100%)',
238-
},
239-
{
240-
icon: '💾',
241-
title: '历史数据归档',
242-
description: '所有报告永久保存,支持按日期浏览,构建你的技术知识库',
243-
gradient: 'linear-gradient(135deg, #34d399 0%, #10b981 100%)',
244-
},
245-
{
246-
icon: '🌐',
247-
title: '在线预览',
248-
description: '基于 Docusaurus 构建的文档站点,随时随地在线阅读报告',
249-
gradient: 'linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%)',
250283
icon: (
251-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
284+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
252285
<circle cx="11" cy="11" r="8"></circle>
253286
<path d="m21 21-4.35-4.35"></path>
254-
<path d="M16 11h-6"></path>
255-
<path d="M11 16v-6"></path>
256287
</svg>
257288
),
258-
title: '实时数据采集',
289+
title: '智能数据采集',
259290
description: '每日自动爬取 GitHub Trending 页面,获取最新热门项目数据,包括 Star、Fork、语言等详细信息',
260291
gradient: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
261292
},
262293
{
263294
icon: (
264-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
295+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
265296
<path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5"></path>
266297
<path d="M8.5 8.5a2.5 2.5 0 0 1 3.5-2.3"></path>
267298
<path d="M12 6V2"></path>
268299
</svg>
269300
),
270-
title: 'AI 智能分析',
301+
title: 'LLM 深度分析',
271302
description: '利用大语言模型对项目进行深度分析,提供技术洞察、趋势预测和学习建议',
272303
gradient: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
273304
},
274305
{
275306
icon: (
276-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
307+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
277308
<path d="M3 3v18h18"></path>
278309
<path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"></path>
279310
</svg>
280311
),
281-
title: '可视化报告',
282-
description: '生成精美的 Markdown 报告,支持在线浏览,数据清晰直观',
312+
title: '精美可视化',
313+
description: '生成结构化的 Markdown 报告,表格、图表、代码示例一应俱全,数据清晰直观',
283314
gradient: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
284315
},
285316
{
286317
icon: (
287-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
288-
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
289-
<polyline points="22,6 12,13 2,6"></polyline>
318+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
319+
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
290320
</svg>
291321
),
292-
title: '邮件推送',
293-
description: '支持邮件订阅,每日报告自动推送到你的邮箱,不错过任何热门项目',
294-
gradient: 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)',
322+
title: '全自动流水线',
323+
description: '基于 GitHub Actions 实现全流程自动化,每日定时触发,零人工干预,稳定可靠',
324+
gradient: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
295325
},
296326
{
297327
icon: (
298-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
328+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
299329
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
300330
<polyline points="3.27,6.96 12,12.01 20.73,6.96"></polyline>
301331
<line x1="12" y1="22.08" x2="12" y2="12"></line>
302332
</svg>
303333
),
304-
title: '数据持久化',
305-
description: '所有历史报告永久保存,支持回顾和数据分析,构建你的技术知识库',
334+
title: '历史数据归档',
335+
description: '所有报告永久保存,支持按日期浏览和数据分析,构建你的技术知识库',
306336
gradient: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)',
307337
},
308338
{
309339
icon: (
310-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
311-
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
340+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
341+
<circle cx="12" cy="12" r="10"></circle>
342+
<path d="M2 12h20"></path>
343+
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
312344
</svg>
313345
),
314-
title: '全自动化',
315-
description: '基于 GitHub Actions 实现全流程自动化,零人工干预,稳定可靠',
316-
gradient: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
317-
>>>>>>> cdbf845 (feat(ui): 替换图标为svg并优化样式)
346+
title: '在线预览',
347+
description: '基于 Docusaurus 构建的文档站点,随时随地在线阅读报告,响应式设计',
348+
gradient: 'linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%)',
318349
},
319350
];
320351

@@ -401,6 +432,7 @@ function CTASection() {
401432
export default function Home() {
402433
return (
403434
<Layout title="首页" description="每日 GitHub 热门项目追踪与 AI 分析报告">
435+
<ScrollProgress />
404436
<HomepageHeader />
405437
<main>
406438
<StatsSection />
@@ -410,4 +442,4 @@ export default function Home() {
410442
</main>
411443
</Layout>
412444
);
413-
}
445+
}

0 commit comments

Comments
 (0)