grweb 0.1.4

A high-performance Rust Web framework based on gorust coroutine runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>grweb - 高性能 Rust Web 框架,Go 风格并发</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #0a0f1e 0%, #0f172a 100%);
            color: #e2e8f0;
            line-height: 1.6;
            overflow: hidden;
            height: 100vh;
        }

        /* 动态背景粒子效果 */
        .particles {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 0;
        }

        .particle {
            position: absolute;
            background: rgba(96, 165, 250, 0.3);
            border-radius: 50%;
            animation: float 20s infinite ease-in-out;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
            10% { opacity: 0.5; }
            90% { opacity: 0.5; }
            100% { transform: translateY(-100px) translateX(50px); opacity: 0; }
        }

        /* 分页容器 */
        .pages-container {
            height: 100vh;
            width: 100%;
            overflow-y: scroll;
            scroll-snap-type: y mandatory;
            scroll-behavior: smooth;
            position: relative;
            z-index: 1;
        }

        /* 隐藏滚动条但保持功能 */
        .pages-container::-webkit-scrollbar {
            display: none;
        }
        
        .pages-container {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        .page {
            height: 100vh;
            width: 100%;
            scroll-snap-align: start;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow-y: auto;
        }

        .page-content {
            max-width: 1280px;
            width: 100%;
            padding: 2rem;
            animation: fadeInUp 0.8s ease;
        }

        /* 导航指示器 */
        .nav-indicator {
            position: fixed;
            right: 2rem;
            top: 50%;
            transform: translateY(-50%);
            z-index: 100;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .nav-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #475569;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .nav-dot.active {
            background: #60a5fa;
            transform: scale(1.5);
            box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
        }

        .nav-dot:hover {
            background: #94a3b8;
            transform: scale(1.2);
        }

        /* 键盘提示 */
        .keyboard-hint {
            position: fixed;
            bottom: 2rem;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(30, 41, 59, 0.8);
            backdrop-filter: blur(10px);
            padding: 0.5rem 1rem;
            border-radius: 30px;
            font-size: 0.75rem;
            color: #94a3b8;
            z-index: 100;
            display: flex;
            gap: 1rem;
            border: 1px solid rgba(100, 116, 139, 0.3);
        }

        .keyboard-hint span {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
        }

        .key {
            background: #1e293b;
            padding: 0.2rem 0.5rem;
            border-radius: 6px;
            font-family: monospace;
            font-size: 0.7rem;
            border: 1px solid #475569;
        }

        /* 导航栏 */
        .navbar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            padding: 1.5rem 2rem;
            border-bottom: 1px solid rgba(100, 116, 139, 0.2);
            backdrop-filter: blur(10px);
            background: rgba(15, 23, 42, 0.8);
            z-index: 100;
            animation: slideDown 0.5s ease;
        }

        .nav-content {
            max-width: 1280px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 700;
            background: linear-gradient(135deg, #60a5fa, #a78bfa);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: glow 3s ease-in-out infinite;
        }

        .github-link {
            background: #334155;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            text-decoration: none;
            color: #f1f5f9;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .github-link:hover {
            background: #475569;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
        }

        @keyframes slideDown {
            from { transform: translateY(-100%); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        @keyframes glow {
            0%, 100% { opacity: 0.8; }
            50% { opacity: 1; text-shadow: 0 0 10px rgba(96, 165, 250, 0.5); }
        }

        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(30px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes fadeInScale {
            from { opacity: 0; transform: scale(0.9); }
            to { opacity: 1; transform: scale(1); }
        }

        /* 按钮样式 */
        .btn {
            display: inline-block;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 600;
            text-decoration: none;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
        }

        .btn-primary {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
            color: white;
            border: none;
            box-shadow: 0 4px 14px 0 rgba(59,130,246,0.4);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px 0 rgba(59,130,246,0.6);
        }

        .btn-outline {
            border: 1px solid #60a5fa;
            color: #60a5fa;
            background: transparent;
        }

        .btn-outline:hover {
            background: rgba(96, 165, 250, 0.1);
            transform: translateY(-1px);
        }

        .badge {
            background: rgba(96, 165, 250, 0.2);
            border: 1px solid #3b82f6;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.85rem;
            display: inline-block;
            margin-bottom: 1rem;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
            50% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
        }

        .hero h1 {
            font-size: 3.5rem;
            font-weight: 800;
            background: linear-gradient(135deg, #fff, #94a3b8);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            margin-bottom: 1rem;
        }

        .hero .tagline {
            font-size: 1.25rem;
            color: #94a3b8;
            margin-bottom: 2rem;
            max-width: 700px;
            margin-left: auto;
            margin-right: auto;
        }

        /* 性能卡片 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1.5rem;
            margin: 3rem 0;
        }

        .stat-card {
            background: rgba(30, 41, 59, 0.6);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(100, 116, 139, 0.3);
            border-radius: 16px;
            padding: 1.5rem;
            text-align: center;
            transition: all 0.3s;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            border-color: #60a5fa;
        }

        .stat-number {
            font-size: 2.5rem;
            font-weight: 800;
            color: #60a5fa;
            margin-bottom: 0.5rem;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1.5rem;
            margin-top: 2rem;
        }

        .feature-card {
            background: rgba(30, 41, 59, 0.4);
            border-radius: 16px;
            padding: 1.5rem;
            border: 1px solid rgba(100, 116, 139, 0.2);
            transition: all 0.3s;
        }

        .feature-card:hover {
            transform: translateY(-5px);
            border-color: #60a5fa;
        }

        .feature-icon {
            font-size: 2.5rem;
            margin-bottom: 1rem;
        }

        .code-section {
            background: linear-gradient(135deg, #0f172a, #1e293b);
            border-radius: 16px;
            padding: 1.5rem;
            border: 1px solid #334155;
        }

        pre {
            background: #0f172a;
            padding: 1rem;
            border-radius: 8px;
            overflow-x: auto;
            font-size: 0.8rem;
            border-left: 3px solid #60a5fa;
        }

        code {
            font-family: 'Monaco', monospace;
            color: #a5f3fc;
        }

        .comparison-table {
            width: 100%;
            border-collapse: collapse;
            background: rgba(30, 41, 59, 0.4);
            border-radius: 12px;
            overflow: hidden;
        }

        .comparison-table th,
        .comparison-table td {
            padding: 0.75rem;
            text-align: left;
            border-bottom: 1px solid #334155;
        }

        .highlight {
            color: #60a5fa;
            font-weight: 700;
        }

        .section-title {
            font-size: 2rem;
            font-weight: 700;
            text-align: center;
            margin-bottom: 2rem;
            color: #f1f5f9;
        }

        .text-center { text-align: center; }
        .mt-4 { margin-top: 2rem; }
        .mb-4 { margin-bottom: 2rem; }

        @media (max-width: 768px) {
            .hero h1 { font-size: 2rem; }
            .section-title { font-size: 1.5rem; }
            .page-content { padding: 5rem 1rem 2rem; }
            .nav-indicator { right: 1rem; }
        }
    </style>
</head>
<body>
    <div class="particles" id="particles"></div>

    <nav class="navbar">
        <div class="nav-content">
            <div class="logo">⚡ grweb</div>
            <a href="https://github.com/WLmutou/grweb" class="github-link" target="_blank">GitHub ↗</a>
        </div>
    </nav>

    <div class="nav-indicator" id="navIndicator"></div>
    <div class="keyboard-hint">
        <span>⬅️ <span class="key"></span> / <span class="key"></span></span>
        <span>➡️ <span class="key"></span> / <span class="key"></span></span>
        <span>滑动鼠标滚轮</span>
    </div>

    <div class="pages-container" id="pagesContainer">
        <!-- 第1页:Hero + 性能数据 -->
        <div class="page" data-page="0">
            <div class="page-content">
                <div class="hero text-center">
                    <div class="badge">✨ v0.1.0 正式发布</div>
                    <h1>grweb: <br> Go 风格并发,Rust 极致性能</h1>
                    <p class="tagline">
                        一个轻量级、高性能的 Web 框架,将 Go 语言的并发模型与 Rust 的零成本抽象完美结合。
                        体验 M:N 协程调度带来的极致性能。
                    </p>
                    <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;">
                        <a href="https://github.com/WLmutou/grweb" class="btn btn-primary">⭐ GitHub 仓库</a>
                        <a href="https://crates.io/crates/grweb" class="btn btn-outline">📦 crates.io</a>
                        <a href="#" class="btn btn-outline">📖 文档</a>
                    </div>
                </div>

                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-number" data-target="110038">0</div>
                        <div class="stat-label">QPS</div>
                        <div class="stat-unit">requests/sec</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number" data-target="124">0</div>
                        <div class="stat-label">延迟 (平均)</div>
                        <div class="stat-unit">microseconds</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number" data-target="483">0</div>
                        <div class="stat-label">吞吐量</div>
                        <div class="stat-unit">MB/s</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number" data-target="99">0</div>
                        <div class="stat-label">稳定度</div>
                        <div class="stat-unit">高负载下</div>
                    </div>
                </div>
                <p class="text-center" style="font-size: 0.85rem; color: #64748b;">
                    * 测试环境: 4 线程, 100 连接, wrk 压测, 响应大小约 4.3KB (Keep-Alive 开启)
                </p>
            </div>
        </div>

        <!-- 第2页:核心特性 -->
        <div class="page" data-page="1">
            <div class="page-content">
                <h2 class="section-title">为什么选择 grweb?</h2>
                <div class="features-grid">
                    <div class="feature-card">
                        <div class="feature-icon"></div>
                        <div class="feature-title">110k QPS 真实性能</div>
                        <div>实测超越 Tokio/hyper,吞吐量碾压 Go/Java/Node.js。</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">🎯</div>
                        <div class="feature-title">M:N 协程调度</div>
                        <div>用户态轻量级任务,工作窃取算法实现自动负载均衡。</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">🔗</div>
                        <div class="feature-title">Channel 通信</div>
                        <div>类 Go 的 channel,安全高效的协程间消息传递。</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">💾</div>
                        <div class="feature-title">极低内存占用</div>
                        <div>基础运行时内存仅 ~3MB,适合容器化部署。</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">🔁</div>
                        <div class="feature-title">HTTP Keep-Alive</div>
                        <div>连接复用,吞吐量提升 6 倍,减少 TCP 握手开销。</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">🦀</div>
                        <div class="feature-title">100% Rust</div>
                        <div>内存安全,零成本抽象,无畏并发。</div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 第3页:代码示例 -->
        <div class="page" data-page="2">
            <div class="page-content">
                <h2 class="section-title">📄 代码示例</h2>
                <div class="code-section">
                    <pre><code>use grweb::{Server, Router, Response};

fn main() {
    let mut router = Router::new();
    
    router.get("/", |_| {
        Response::html("&lt;h1&gt;Hello grweb!&lt;/h1&gt;&lt;p&gt;高性能 Web 框架&lt;/p&gt;")
    });
    
    router.get("/hello/:name", |ctx| {
        let name = ctx.param("name").unwrap_or("World");
        Response::json(&format!(r#"{{"message": "Hello, {}!"}}"#, name))
    });
    
    Server::new(router).run(":8080").unwrap();
}</code></pre>
                    <div class="text-center mt-4">
                        <a href="https://github.com/WLmutou/grweb/tree/main/examples" class="btn btn-outline">查看完整示例 →</a>
                    </div>
                </div>
            </div>
        </div>

        <!-- 第4页:性能对比表 -->
        <div class="page" data-page="3">
            <div class="page-content">
                <h2 class="section-title">与世界主流框架对比</h2>
                <table class="comparison-table">
                    <thead>
                        <tr><th>框架</th><th>QPS</th><th>平均延迟</th><th>吞吐量</th><th>内存占用</th></tr>
                    </thead>
                    <tbody>
                        <tr><td class="highlight">✨ grweb</td><td class="highlight">110,038</td><td class="highlight">1.24 ms</td><td class="highlight">483 MB/s</td><td class="highlight">~3 MB</td></tr>
                        <tr><td>Rust (Actix-Web)</td><td>~100,000</td><td>~1.50 ms</td><td>~100 MB/s</td><td>~8 MB</td></tr>
                        <tr><td>Go (net/http)</td><td>~48,000</td><td>~2.50 ms</td><td>~50 MB/s</td><td>~25 MB</td></tr>
                        <tr><td>Java (Spring Boot)</td><td>~38,000</td><td>~3.50 ms</td><td>~40 MB/s</td><td>~150 MB</td></tr>
                        <tr><td>Node.js (Express)</td><td>~18,000</td><td>~8.00 ms</td><td>~20 MB/s</td><td>~50 MB</td></tr>
                    </tbody>
                </table>
                <p class="text-center" style="font-size: 0.8rem; margin-top: 1rem;">* 数据基于相同硬件环境测试,grweb 开启 Keep-Alive</p>
            </div>
        </div>

        <!-- 第5页:快速开始 -->
        <div class="page" data-page="4">
            <div class="page-content">
                <h2 class="section-title">🚀 快速开始</h2>
                <div class="code-section">
                    <pre><code># 添加依赖
cargo add grweb

# 创建项目
cargo new my_grweb_app
cd my_grweb_app

# 运行示例
cargo run --example simple_server</code></pre>
                    <div class="text-center mt-4" style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;">
                        <a href="https://github.com/WLmutou/grweb" class="btn btn-primary">GitHub 仓库</a>
                        <a href="#" class="btn btn-outline">📚 阅读文档</a>
                        <a href="#" class="btn btn-outline">🐛 报告问题</a>
                    </div>
                </div>
                <div class="text-center mt-4">
                    <p style="color: #64748b;">❤️ 用 Rust 实现 Go 的并发梦想 | grweb - 开源 · 高性能 · 现代化</p>
                    <p style="margin-top: 1rem; font-size: 0.8rem;">⭐ 如果喜欢这个项目,欢迎给个 Star!</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 粒子背景
        function createParticles() {
            const container = document.getElementById('particles');
            for (let i = 0; i < 50; i++) {
                const particle = document.createElement('div');
                particle.className = 'particle';
                const size = Math.random() * 4 + 1;
                particle.style.width = `${size}px`;
                particle.style.height = `${size}px`;
                particle.style.left = `${Math.random() * 100}%`;
                particle.style.animationDelay = `${Math.random() * 20}s`;
                particle.style.animationDuration = `${15 + Math.random() * 10}s`;
                container.appendChild(particle);
            }
        }

        // 数字动画
        function animateNumber(element, target) {
            let current = 0;
            const increment = target / 50;
            const timer = setInterval(() => {
                current += increment;
                if (current >= target) {
                    element.textContent = target;
                    clearInterval(timer);
                } else {
                    element.textContent = Math.floor(current);
                }
            }, 16);
        }

        // 触发数字动画(只在第1页可见时触发)
        let numbersAnimated = false;
        function checkAndAnimateNumbers() {
            if (numbersAnimated) return;
            const firstPage = document.querySelector('.page[data-page="0"]');
            if (firstPage && isElementInViewport(firstPage)) {
                const statNumbers = document.querySelectorAll('.stat-number');
                statNumbers.forEach(num => {
                    const target = parseInt(num.dataset.target);
                    if (target && num.textContent === '0') {
                        animateNumber(num, target);
                    }
                });
                numbersAnimated = true;
            }
        }

        function isElementInViewport(el) {
            const rect = el.getBoundingClientRect();
            return rect.top >= 0 && rect.top < window.innerHeight;
        }

        // 分页导航
        const container = document.getElementById('pagesContainer');
        const pages = document.querySelectorAll('.page');
        const totalPages = pages.length;
        let currentPage = 0;

        function createNavDots() {
            const indicator = document.getElementById('navIndicator');
            indicator.innerHTML = '';
            for (let i = 0; i < totalPages; i++) {
                const dot = document.createElement('div');
                dot.className = 'nav-dot';
                if (i === currentPage) dot.classList.add('active');
                dot.addEventListener('click', () => goToPage(i));
                indicator.appendChild(dot);
            }
        }

        function updateNavDots() {
            const dots = document.querySelectorAll('.nav-dot');
            dots.forEach((dot, idx) => {
                if (idx === currentPage) dot.classList.add('active');
                else dot.classList.remove('active');
            });
        }

        function goToPage(pageIndex) {
            if (pageIndex < 0 || pageIndex >= totalPages) return;
            currentPage = pageIndex;
            const targetPage = pages[currentPage];
            targetPage.scrollIntoView({ behavior: 'smooth', block: 'start' });
            updateNavDots();
        }

        function handleKeydown(e) {
            if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
                e.preventDefault();
                goToPage(currentPage + 1);
            } else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
                e.preventDefault();
                goToPage(currentPage - 1);
            }
        }

        // 监听滚动更新当前页
        function updateCurrentPageOnScroll() {
            let bestMatch = 0;
            let bestDistance = Infinity;
            pages.forEach((page, idx) => {
                const rect = page.getBoundingClientRect();
                const distance = Math.abs(rect.top);
                if (distance < bestDistance) {
                    bestDistance = distance;
                    bestMatch = idx;
                }
            });
            if (bestMatch !== currentPage) {
                currentPage = bestMatch;
                updateNavDots();
                checkAndAnimateNumbers();
            }
        }

        // 初始化
        window.addEventListener('load', () => {
            createParticles();
            createNavDots();
            checkAndAnimateNumbers();
            
            container.addEventListener('scroll', updateCurrentPageOnScroll);
            window.addEventListener('keydown', handleKeydown);
            
            // 监听动画完成后的数字触发
            setTimeout(checkAndAnimateNumbers, 500);
            setTimeout(checkAndAnimateNumbers, 1000);
        });
    </script>
</body>
</html>