amaozjy commited on
Commit
ff15706
·
verified ·
1 Parent(s): e463b8a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +828 -19
index.html CHANGED
@@ -1,19 +1,828 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>你好 - 多语言问候应用</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ :root {
15
+ --primary-color: #6366f1;
16
+ --secondary-color: #8b5cf6;
17
+ --accent-color: #ec4899;
18
+ --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
19
+ --card-bg: rgba(255, 255, 255, 0.95);
20
+ --text-primary: #1f2937;
21
+ --text-secondary: #6b7280;
22
+ --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
23
+ }
24
+
25
+ body {
26
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
27
+ background: var(--bg-gradient);
28
+ min-height: 100vh;
29
+ display: flex;
30
+ justify-content: center;
31
+ align-items: center;
32
+ padding: 20px;
33
+ overflow-x: hidden;
34
+ }
35
+
36
+ .container {
37
+ max-width: 1200px;
38
+ width: 100%;
39
+ animation: fadeIn 0.8s ease-out;
40
+ }
41
+
42
+ @keyframes fadeIn {
43
+ from {
44
+ opacity: 0;
45
+ transform: translateY(20px);
46
+ }
47
+ to {
48
+ opacity: 1;
49
+ transform: translateY(0);
50
+ }
51
+ }
52
+
53
+ .header {
54
+ text-align: center;
55
+ margin-bottom: 40px;
56
+ position: relative;
57
+ }
58
+
59
+ .header h1 {
60
+ font-size: clamp(2.5rem, 8vw, 4rem);
61
+ color: white;
62
+ font-weight: 800;
63
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
64
+ margin-bottom: 10px;
65
+ animation: glow 2s ease-in-out infinite alternate;
66
+ }
67
+
68
+ @keyframes glow {
69
+ from {
70
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
71
+ }
72
+ to {
73
+ text-shadow: 2px 2px 20px rgba(255, 255, 255, 0.5);
74
+ }
75
+ }
76
+
77
+ .header p {
78
+ color: rgba(255, 255, 255, 0.9);
79
+ font-size: 1.2rem;
80
+ opacity: 0;
81
+ animation: fadeIn 1s ease-out 0.5s forwards;
82
+ }
83
+
84
+ .anycoder-link {
85
+ position: absolute;
86
+ top: -30px;
87
+ right: 0;
88
+ background: rgba(255, 255, 255, 0.2);
89
+ padding: 8px 16px;
90
+ border-radius: 20px;
91
+ color: white;
92
+ text-decoration: none;
93
+ font-size: 0.9rem;
94
+ backdrop-filter: blur(10px);
95
+ transition: all 0.3s ease;
96
+ }
97
+
98
+ .anycoder-link:hover {
99
+ background: rgba(255, 255, 255, 0.3);
100
+ transform: translateY(-2px);
101
+ }
102
+
103
+ .main-content {
104
+ display: grid;
105
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
106
+ gap: 25px;
107
+ margin-bottom: 40px;
108
+ }
109
+
110
+ .greeting-card {
111
+ background: var(--card-bg);
112
+ border-radius: 20px;
113
+ padding: 30px;
114
+ box-shadow: var(--shadow);
115
+ backdrop-filter: blur(10px);
116
+ transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
117
+ cursor: pointer;
118
+ position: relative;
119
+ overflow: hidden;
120
+ }
121
+
122
+ .greeting-card::before {
123
+ content: '';
124
+ position: absolute;
125
+ top: 0;
126
+ left: -100%;
127
+ width: 100%;
128
+ height: 100%;
129
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
130
+ transition: left 0.5s;
131
+ }
132
+
133
+ .greeting-card:hover::before {
134
+ left: 100%;
135
+ }
136
+
137
+ .greeting-card:hover {
138
+ transform: translateY(-10px) scale(1.02);
139
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
140
+ }
141
+
142
+ .greeting-text {
143
+ font-size: 2.5rem;
144
+ font-weight: 700;
145
+ color: var(--primary-color);
146
+ margin-bottom: 10px;
147
+ transition: all 0.3s ease;
148
+ }
149
+
150
+ .greeting-card:hover .greeting-text {
151
+ color: var(--accent-color);
152
+ transform: scale(1.1);
153
+ }
154
+
155
+ .language-name {
156
+ font-size: 1.1rem;
157
+ color: var(--text-secondary);
158
+ font-weight: 500;
159
+ }
160
+
161
+ .pronunciation {
162
+ font-size: 0.9rem;
163
+ color: var(--text-secondary);
164
+ opacity: 0.8;
165
+ margin-top: 5px;
166
+ font-style: italic;
167
+ }
168
+
169
+ .interactive-section {
170
+ background: var(--card-bg);
171
+ border-radius: 20px;
172
+ padding: 40px;
173
+ box-shadow: var(--shadow);
174
+ text-align: center;
175
+ margin-bottom: 40px;
176
+ }
177
+
178
+ .interactive-section h2 {
179
+ font-size: 2rem;
180
+ color: var(--text-primary);
181
+ margin-bottom: 20px;
182
+ }
183
+
184
+ .input-group {
185
+ display: flex;
186
+ gap: 15px;
187
+ justify-content: center;
188
+ flex-wrap: wrap;
189
+ margin-bottom: 30px;
190
+ }
191
+
192
+ .name-input {
193
+ padding: 15px 25px;
194
+ border: 2px solid #e5e7eb;
195
+ border-radius: 50px;
196
+ font-size: 1.1rem;
197
+ min-width: 250px;
198
+ transition: all 0.3s ease;
199
+ outline: none;
200
+ }
201
+
202
+ .name-input:focus {
203
+ border-color: var(--primary-color);
204
+ box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
205
+ }
206
+
207
+ .generate-btn {
208
+ padding: 15px 30px;
209
+ background: var(--primary-color);
210
+ color: white;
211
+ border: none;
212
+ border-radius: 50px;
213
+ font-size: 1.1rem;
214
+ font-weight: 600;
215
+ cursor: pointer;
216
+ transition: all 0.3s ease;
217
+ position: relative;
218
+ overflow: hidden;
219
+ }
220
+
221
+ .generate-btn::before {
222
+ content: '';
223
+ position: absolute;
224
+ top: 50%;
225
+ left: 50%;
226
+ width: 0;
227
+ height: 0;
228
+ background: rgba(255, 255, 255, 0.3);
229
+ border-radius: 50%;
230
+ transform: translate(-50%, -50%);
231
+ transition: width 0.6s, height 0.6s;
232
+ }
233
+
234
+ .generate-btn:hover::before {
235
+ width: 300px;
236
+ height: 300px;
237
+ }
238
+
239
+ .generate-btn:hover {
240
+ background: var(--secondary-color);
241
+ transform: translateY(-2px);
242
+ box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
243
+ }
244
+
245
+ .custom-greeting {
246
+ font-size: 2rem;
247
+ color: var(--primary-color);
248
+ font-weight: 700;
249
+ margin-top: 20px;
250
+ opacity: 0;
251
+ transform: translateY(20px);
252
+ transition: all 0.5s ease;
253
+ }
254
+
255
+ .custom-greeting.show {
256
+ opacity: 1;
257
+ transform: translateY(0);
258
+ }
259
+
260
+ .animation-section {
261
+ background: var(--card-bg);
262
+ border-radius: 20px;
263
+ padding: 40px;
264
+ box-shadow: var(--shadow);
265
+ text-align: center;
266
+ }
267
+
268
+ .animated-characters {
269
+ display: flex;
270
+ justify-content: center;
271
+ gap: 15px;
272
+ flex-wrap: wrap;
273
+ margin-top: 30px;
274
+ }
275
+
276
+ .char-box {
277
+ width: 80px;
278
+ height: 80px;
279
+ background: var(--primary-color);
280
+ border-radius: 15px;
281
+ display: flex;
282
+ align-items: center;
283
+ justify-content: center;
284
+ color: white;
285
+ font-size: 2rem;
286
+ font-weight: 700;
287
+ cursor: pointer;
288
+ transition: all 0.3s ease;
289
+ position: relative;
290
+ }
291
+
292
+ .char-box:hover {
293
+ background: var(--accent-color);
294
+ transform: rotate(360deg) scale(1.2);
295
+ }
296
+
297
+ .char-box::after {
298
+ content: attr(data-pinyin);
299
+ position: absolute;
300
+ bottom: -25px;
301
+ font-size: 0.8rem;
302
+ color: var(--text-secondary);
303
+ opacity: 0;
304
+ transition: opacity 0.3s ease;
305
+ }
306
+
307
+ .char-box:hover::after {
308
+ opacity: 1;
309
+ }
310
+
311
+ .wave-animation {
312
+ animation: wave 2s ease-in-out infinite;
313
+ }
314
+
315
+ @keyframes wave {
316
+ 0%, 100% {
317
+ transform: translateY(0);
318
+ }
319
+ 50% {
320
+ transform: translateY(-20px);
321
+ }
322
+ }
323
+
324
+ .pulse-animation {
325
+ animation: pulse 1.5s ease-in-out infinite;
326
+ }
327
+
328
+ @keyframes pulse {
329
+ 0% {
330
+ transform: scale(1);
331
+ box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
332
+ }
333
+ 70% {
334
+ transform: scale(1.05);
335
+ box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
336
+ }
337
+ 100% {
338
+ transform: scale(1);
339
+ box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
340
+ }
341
+ }
342
+
343
+ .stats-section {
344
+ display: grid;
345
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
346
+ gap: 20px;
347
+ margin-top: 40px;
348
+ }
349
+
350
+ .stat-card {
351
+ background: rgba(255, 255, 255, 0.2);
352
+ backdrop-filter: blur(10px);
353
+ border-radius: 15px;
354
+ padding: 25px;
355
+ text-align: center;
356
+ color: white;
357
+ border: 1px solid rgba(255, 255, 255, 0.3);
358
+ transition: all 0.3s ease;
359
+ }
360
+
361
+ .stat-card:hover {
362
+ background: rgba(255, 255, 255, 0.3);
363
+ transform: translateY(-5px);
364
+ }
365
+
366
+ .stat-number {
367
+ font-size: 2.5rem;
368
+ font-weight: 800;
369
+ margin-bottom: 5px;
370
+ }
371
+
372
+ .stat-label {
373
+ font-size: 1rem;
374
+ opacity: 0.9;
375
+ }
376
+
377
+ .floating-emoji {
378
+ position: fixed;
379
+ font-size: 2rem;
380
+ pointer-events: none;
381
+ animation: float 4s ease-in-out infinite;
382
+ z-index: 1000;
383
+ }
384
+
385
+ @keyframes float {
386
+ 0% {
387
+ transform: translateY(0) rotate(0deg);
388
+ opacity: 0.8;
389
+ }
390
+ 50% {
391
+ transform: translateY(-30px) rotate(180deg);
392
+ opacity: 0.4;
393
+ }
394
+ 100% {
395
+ transform: translateY(0) rotate(360deg);
396
+ opacity: 0.8;
397
+ }
398
+ }
399
+
400
+ .footer {
401
+ text-align: center;
402
+ margin-top: 40px;
403
+ color: rgba(255, 255, 255, 0.8);
404
+ font-size: 1rem;
405
+ }
406
+
407
+ @media (max-width: 768px) {
408
+ .header h1 {
409
+ font-size: 2.5rem;
410
+ }
411
+
412
+ .greeting-text {
413
+ font-size: 2rem;
414
+ }
415
+
416
+ .input-group {
417
+ flex-direction: column;
418
+ align-items: center;
419
+ }
420
+
421
+ .name-input {
422
+ min-width: 100%;
423
+ max-width: 300px;
424
+ }
425
+
426
+ .animated-characters {
427
+ gap: 10px;
428
+ }
429
+
430
+ .char-box {
431
+ width: 60px;
432
+ height: 60px;
433
+ font-size: 1.5rem;
434
+ }
435
+ }
436
+
437
+ @media (max-width: 480px) {
438
+ .main-content {
439
+ grid-template-columns: 1fr;
440
+ }
441
+
442
+ .stats-section {
443
+ grid-template-columns: repeat(2, 1fr);
444
+ }
445
+ }
446
+ </style>
447
+ </head>
448
+ <body>
449
+ <div class="container">
450
+ <header class="header">
451
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
452
+ Built with anycoder
453
+ </a>
454
+ <h1>你好 👋</h1>
455
+ <p>探索世界各地的温暖问候</p>
456
+ </header>
457
+
458
+ <main class="main-content">
459
+ <div class="greeting-card" onclick="playGreeting('你好', 'zh-CN')">
460
+ <div class="greeting-text">你好</div>
461
+ <div class="language-name">中文 (Chinese)</div>
462
+ <div class="pronunciation">Nǐ hǎo</div>
463
+ </div>
464
+
465
+ <div class="greeting-card" onclick="playGreeting('Hello', 'en-US')">
466
+ <div class="greeting-text">Hello</div>
467
+ <div class="language-name">英语 (English)</div>
468
+ <div class="pronunciation">/həˈloʊ/</div>
469
+ </div>
470
+
471
+ <div class="greeting-card" onclick="playGreeting('Bonjour', 'fr-FR')">
472
+ <div class="greeting-text">Bonjour</div>
473
+ <div class="language-name">法语 (French)</div>
474
+ <div class="pronunciation">/bɔ̃.ʒuʁ/</div>
475
+ </div>
476
+
477
+ <div class="greeting-card" onclick="playGreeting('Hola', 'es-ES')">
478
+ <div class="greeting-text">Hola</div>
479
+ <div class="language-name">西班牙语 (Spanish)</div>
480
+ <div class="pronunciation">/ˈo.la/</div>
481
+ </div>
482
+
483
+ <div class="greeting-card" onclick="playGreeting('Konnichiwa', 'ja-JP')">
484
+ <div class="greeting-text">こんにちは</div>
485
+ <div class="language-name">日语 (Japanese)</div>
486
+ <div class="pronunciation">Konnichiwa</div>
487
+ </div>
488
+
489
+ <div class="greeting-card" onclick="playGreeting('Annyeonghaseyo', 'ko-KR')">
490
+ <div class="greeting-text">안녕하세요</div>
491
+ <div class="language-name">韩语 (Korean)</div>
492
+ <div class="pronunciation">Annyeonghaseyo</div>
493
+ </div>
494
+
495
+ <div class="greeting-card" onclick="playGreeting('Guten Tag', 'de-DE')">
496
+ <div class="greeting-text">Guten Tag</div>
497
+ <div class="language-name">德语 (German)</div>
498
+ <div class="pronunciation">/ˈɡuːtn̩ taːk/</div>
499
+ </div>
500
+
501
+ <div class="greeting-card" onclick="playGreeting('Ciao', 'it-IT')">
502
+ <div class="greeting-text">Ciao</div>
503
+ <div class="language-name">意大利语 (Italian)</div>
504
+ <div class="pronunciation">/ˈtʃa.o/</div>
505
+ </div>
506
+
507
+ <div class="greeting-card" onclick="playGreeting('Salam', 'ar-SA')">
508
+ <div class="greeting-text">سلام</div>
509
+ <div class="language-name">阿拉伯语 (Arabic)</div>
510
+ <div class="pronunciation">/saˈlaːm/</div>
511
+ </div>
512
+ </main>
513
+
514
+ <section class="interactive-section">
515
+ <h2>个性化问候生成器</h2>
516
+ <div class="input-group">
517
+ <input type="text" class="name-input" id="nameInput" placeholder="请输入您的名字..." maxlength="20">
518
+ <button class="generate-btn" onclick="generatePersonalizedGreeting()">生成问候</button>
519
+ </div>
520
+ <div class="custom-greeting" id="customGreeting"></div>
521
+ </section>
522
+
523
+ <section class="animation-section">
524
+ <h2>点击汉字体验动画</h2>
525
+ <div class="animated-characters">
526
+ <div class="char-box wave-animation" data-pinyin="nǐ" onclick="animateCharacter(this)">你</div>
527
+ <div class="char-box pulse-animation" data-pinyin="hǎo" onclick="animateCharacter(this)">好</div>
528
+ <div class="char-box" data-pinyin="shì" onclick="animateCharacter(this)">世</div>
529
+ <div class="char-box" data-pinyin="jiè" onclick="animateCharacter(this)">界</div>
530
+ </div>
531
+ </section>
532
+
533
+ <section class="stats-section">
534
+ <div class="stat-card">
535
+ <div class="stat-number" id="greetingCount">0</div>
536
+ <div class="stat-label">问候次数</div>
537
+ </div>
538
+ <div class="stat-card">
539
+ <div class="stat-number" id="languageCount">9</div>
540
+ <div class="stat-label">支持语言</div>
541
+ </div>
542
+ <div class="stat-card">
543
+ <div class="stat-number" id="characterCount">4</div>
544
+ <div class="stat-label">汉字动画</div>
545
+ </div>
546
+ <div class="stat-card">
547
+ <div class="stat-number" id="happyUsers">∞</div>
548
+ <div class="stat-label">快乐用户</div>
549
+ </div>
550
+ </section>
551
+
552
+ <footer class="footer">
553
+ <p>用问候连接世界 💝 | 每一个"你好"都是温暖的开始</p>
554
+ </footer>
555
+ </div>
556
+
557
+ <script>
558
+ // 初始化统计数据
559
+ let greetingCounter = 0;
560
+ let clickCount = 0;
561
+
562
+ // 从localStorage加载数据
563
+ window.addEventListener('load', () => {
564
+ const savedCount = localStorage.getItem('greetingCount');
565
+ if (savedCount) {
566
+ greetingCounter = parseInt(savedCount);
567
+ updateStats();
568
+ }
569
+
570
+ // 添加随机浮动表情
571
+ createFloatingEmoji();
572
+ setInterval(createFloatingEmoji, 5000);
573
+ });
574
+
575
+ // 播放问候语音
576
+ function playGreeting(text, lang) {
577
+ // 增加计数
578
+ greetingCounter++;
579
+ localStorage.setItem('greetingCount', greetingCounter);
580
+ updateStats();
581
+
582
+ // 创建语音合成
583
+ if ('speechSynthesis' in window) {
584
+ const utterance = new SpeechSynthesisUtterance(text);
585
+ utterance.lang = lang;
586
+ utterance.rate = 0.9;
587
+ utterance.pitch = 1.1;
588
+ speechSynthesis.speak(utterance);
589
+ }
590
+
591
+ // 显示点击效果
592
+ showClickEffect();
593
+
594
+ // 显示提示
595
+ showNotification(`正在播放: ${text}`);
596
+ }
597
+
598
+ // 生成个性化问候
599
+ function generatePersonalizedGreeting() {
600
+ const name = document.getElementById('nameInput').value.trim();
601
+ const greetingElement = document.getElementById('customGreeting');
602
+
603
+ if (!name) {
604
+ showNotification('请输入您的名字!', 'warning');
605
+ return;
606
+ }
607
+
608
+ const greetings = [
609
+ `你好,${name}!很高兴认识你!`,
610
+ `Hello, ${name}! Nice to meet you!`,
611
+ `Bonjour, ${name}! Enchanté!`,
612
+ `Hola, ${name}! Mucho gusto!`,
613
+ `こんにちは、${name}さん!はじめまして!`,
614
+ `안녕하세요, ${name}님! 만나서 반갑습니다!`
615
+ ];
616
+
617
+ const randomGreeting = greetings[Math.floor(Math.random() * greetings.length)];
618
+ greetingElement.textContent = randomGreeting;
619
+ greetingElement.classList.add('show');
620
+
621
+ // 播放语音
622
+ if ('speechSynthesis' in window) {
623
+ const utterance = new SpeechSynthesisUtterance(randomGreeting);
624
+ utterance.lang = randomGreeting.includes('你好') ? 'zh-CN' : 'en-US';
625
+ utterance.rate = 0.9;
626
+ speechSynthesis.speak(utterance);
627
+ }
628
+
629
+ // 添加动画效果
630
+ greetingElement.style.animation = 'none';
631
+ setTimeout(() => {
632
+ greetingElement.style.animation = 'pulse 0.5s ease-in-out';
633
+ }, 10);
634
+
635
+ // 清空输入框
636
+ setTimeout(() => {
637
+ document.getElementById('nameInput').value = '';
638
+ }, 1000);
639
+ }
640
+
641
+ // 动画效果
642
+ function animateCharacter(element) {
643
+ clickCount++;
644
+
645
+ // 添加旋转动画
646
+ element.style.animation = 'none';
647
+ setTimeout(() => {
648
+ element.style.animation = 'spin 0.6s ease-in-out';
649
+ }, 10);
650
+
651
+ // 创建粒子效果
652
+ createParticles(element);
653
+
654
+ // 显示点击次数
655
+ if (clickCount % 5 === 0) {
656
+ showNotification(`太棒了!你已经点击了 ${clickCount} 次!`, 'success');
657
+ }
658
+ }
659
+
660
+ // 创建粒子效果
661
+ function createParticles(element) {
662
+ const rect = element.getBoundingClientRect();
663
+ const centerX = rect.left + rect.width / 2;
664
+ const centerY = rect.top + rect.height / 2;
665
+
666
+ for (let i = 0; i < 8; i++) {
667
+ const particle = document.createElement('div');
668
+ particle.style.cssText = `
669
+ position: fixed;
670
+ width: 6px;
671
+ height: 6px;
672
+ background: ${['#6366f1', '#ec4899', '#8b5cf6', '#f59e0b'][Math.floor(Math.random() * 4)]};
673
+ border-radius: 50%;
674
+ left: ${centerX}px;
675
+ top: ${centerY}px;
676
+ pointer-events: none;
677
+ z-index: 9999;
678
+ `;
679
+
680
+ document.body.appendChild(particle);
681
+
682
+ const angle = (i / 8) * Math.PI * 2;
683
+ const distance = 50 + Math.random() * 30;
684
+ const duration = 800 + Math.random() * 400;
685
+
686
+ particle.animate([
687
+ {
688
+ transform: 'translate(0, 0) scale(1)',
689
+ opacity: 1
690
+ },
691
+ {
692
+ transform: `translate(${Math.cos(angle) * distance}px, ${Math.sin(angle) * distance}px) scale(0)`,
693
+ opacity: 0
694
+ }
695
+ ], {
696
+ duration: duration,
697
+ easing: 'ease-out'
698
+ }).onfinish = () => particle.remove();
699
+ }
700
+ }
701
+
702
+ // 创建浮动表情
703
+ function createFloatingEmoji() {
704
+ const emojis = ['😊', '❤️', '✨', '🌟', '💖', '🎉', '🌈', '💫'];
705
+ const emoji = document.createElement('div');
706
+ emoji.className = 'floating-emoji';
707
+ emoji.textContent = emojis[Math.floor(Math.random() * emojis.length)];
708
+ emoji.style.left = Math.random() * window.innerWidth + 'px';
709
+ emoji.style.top = window.innerHeight + 'px';
710
+ emoji.style.animationDuration = (3 + Math.random() * 2) + 's';
711
+
712
+ document.body.appendChild(emoji);
713
+
714
+ setTimeout(() => emoji.remove(), 5000);
715
+ }
716
+
717
+ // 显示点击效果
718
+ function showClickEffect() {
719
+ const effect = document.createElement('div');
720
+ effect.style.cssText = `
721
+ position: fixed;
722
+ top: 50%;
723
+ left: 50%;
724
+ width: 100px;
725
+ height: 100px;
726
+ border: 3px solid rgba(255, 255, 255, 0.8);
727
+ border-radius: 50%;
728
+ transform: translate(-50%, -50%) scale(0);
729
+ pointer-events: none;
730
+ z-index: 9999;
731
+ `;
732
+
733
+ document.body.appendChild(effect);
734
+
735
+ effect.animate([
736
+ { transform: 'translate(-50%, -50%) scale(0)', opacity: 1 },
737
+ { transform: 'translate(-50%, -50%) scale(2)', opacity: 0 }
738
+ ], {
739
+ duration: 600,
740
+ easing: 'ease-out'
741
+ }).onfinish = () => effect.remove();
742
+ }
743
+
744
+ // 显示通知
745
+ function showNotification(message, type = 'info') {
746
+ const notification = document.createElement('div');
747
+ const colors = {
748
+ info: 'rgba(99, 102, 241, 0.9)',
749
+ success: 'rgba(16, 185, 129, 0.9)',
750
+ warning: 'rgba(245, 158, 11, 0.9)'
751
+ };
752
+
753
+ notification.style.cssText = `
754
+ position: fixed;
755
+ top: 20px;
756
+ right: 20px;
757
+ background: ${colors[type]};
758
+ color: white;
759
+ padding: 15px 25px;
760
+ border-radius: 10px;
761
+ font-weight: 500;
762
+ z-index: 10000;
763
+ transform: translateX(100%);
764
+ transition: transform 0.3s ease;
765
+ backdrop-filter: blur(10px);
766
+ box-shadow: var(--shadow);
767
+ `;
768
+
769
+ notification.textContent = message;
770
+ document.body.appendChild(notification);
771
+
772
+ setTimeout(() => notification.style.transform = 'translateX(0)', 100);
773
+ setTimeout(() => {
774
+ notification.style.transform = 'translateX(100%)';
775
+ setTimeout(() => notification.remove(), 300);
776
+ }, 3000);
777
+ }
778
+
779
+ // 更新统计数据
780
+ function updateStats() {
781
+ const countElement = document.getElementById('greetingCount');
782
+ countElement.textContent = greetingCounter;
783
+
784
+ // 添加数字动画
785
+ countElement.style.transform = 'scale(1.2)';
786
+ countElement.style.color = '#ec4899';
787
+ setTimeout(() => {
788
+ countElement.style.transform = 'scale(1)';
789
+ countElement.style.color = 'white';
790
+ }, 300);
791
+ }
792
+
793
+ // 键盘事件监听
794
+ document.getElementById('nameInput').addEventListener('keypress', (e) => {
795
+ if (e.key === 'Enter') {
796
+ generatePersonalizedGreeting();
797
+ }
798
+ });
799
+
800
+ // 添加CSS动画关键帧
801
+ const style = document.createElement('style');
802
+ style.textContent = `
803
+ @keyframes spin {
804
+ from { transform: rotate(0deg); }
805
+ to { transform: rotate(360deg); }
806
+ }
807
+ `;
808
+ document.head.appendChild(style);
809
+
810
+ // 页面可见性变化时的处理
811
+ document.addEventListener('visibilitychange', () => {
812
+ if (document.hidden) {
813
+ speechSynthesis.cancel();
814
+ }
815
+ });
816
+
817
+ // 随机背景动画
818
+ setInterval(() => {
819
+ const cards = document.querySelectorAll('.greeting-card');
820
+ const randomCard = cards[Math.floor(Math.random() * cards.length)];
821
+ randomCard.style.transform = 'scale(1.05)';
822
+ setTimeout(() => {
823
+ randomCard.style.transform = '';
824
+ }, 200);
825
+ }, 5000);
826
+ </script>
827
+ </body>
828
+ </html>