Spaces:
Running
Running
File size: 26,833 Bytes
ff15706 | 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 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>你好 - 多语言问候应用</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary-color: #6366f1;
--secondary-color: #8b5cf6;
--accent-color: #ec4899;
--bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--card-bg: rgba(255, 255, 255, 0.95);
--text-primary: #1f2937;
--text-secondary: #6b7280;
--shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: var(--bg-gradient);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
overflow-x: hidden;
}
.container {
max-width: 1200px;
width: 100%;
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.header {
text-align: center;
margin-bottom: 40px;
position: relative;
}
.header h1 {
font-size: clamp(2.5rem, 8vw, 4rem);
color: white;
font-weight: 800;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
margin-bottom: 10px;
animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
from {
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
to {
text-shadow: 2px 2px 20px rgba(255, 255, 255, 0.5);
}
}
.header p {
color: rgba(255, 255, 255, 0.9);
font-size: 1.2rem;
opacity: 0;
animation: fadeIn 1s ease-out 0.5s forwards;
}
.anycoder-link {
position: absolute;
top: -30px;
right: 0;
background: rgba(255, 255, 255, 0.2);
padding: 8px 16px;
border-radius: 20px;
color: white;
text-decoration: none;
font-size: 0.9rem;
backdrop-filter: blur(10px);
transition: all 0.3s ease;
}
.anycoder-link:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
}
.main-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 25px;
margin-bottom: 40px;
}
.greeting-card {
background: var(--card-bg);
border-radius: 20px;
padding: 30px;
box-shadow: var(--shadow);
backdrop-filter: blur(10px);
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
cursor: pointer;
position: relative;
overflow: hidden;
}
.greeting-card::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
transition: left 0.5s;
}
.greeting-card:hover::before {
left: 100%;
}
.greeting-card:hover {
transform: translateY(-10px) scale(1.02);
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.greeting-text {
font-size: 2.5rem;
font-weight: 700;
color: var(--primary-color);
margin-bottom: 10px;
transition: all 0.3s ease;
}
.greeting-card:hover .greeting-text {
color: var(--accent-color);
transform: scale(1.1);
}
.language-name {
font-size: 1.1rem;
color: var(--text-secondary);
font-weight: 500;
}
.pronunciation {
font-size: 0.9rem;
color: var(--text-secondary);
opacity: 0.8;
margin-top: 5px;
font-style: italic;
}
.interactive-section {
background: var(--card-bg);
border-radius: 20px;
padding: 40px;
box-shadow: var(--shadow);
text-align: center;
margin-bottom: 40px;
}
.interactive-section h2 {
font-size: 2rem;
color: var(--text-primary);
margin-bottom: 20px;
}
.input-group {
display: flex;
gap: 15px;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 30px;
}
.name-input {
padding: 15px 25px;
border: 2px solid #e5e7eb;
border-radius: 50px;
font-size: 1.1rem;
min-width: 250px;
transition: all 0.3s ease;
outline: none;
}
.name-input:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.generate-btn {
padding: 15px 30px;
background: var(--primary-color);
color: white;
border: none;
border-radius: 50px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.generate-btn::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
background: rgba(255, 255, 255, 0.3);
border-radius: 50%;
transform: translate(-50%, -50%);
transition: width 0.6s, height 0.6s;
}
.generate-btn:hover::before {
width: 300px;
height: 300px;
}
.generate-btn:hover {
background: var(--secondary-color);
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}
.custom-greeting {
font-size: 2rem;
color: var(--primary-color);
font-weight: 700;
margin-top: 20px;
opacity: 0;
transform: translateY(20px);
transition: all 0.5s ease;
}
.custom-greeting.show {
opacity: 1;
transform: translateY(0);
}
.animation-section {
background: var(--card-bg);
border-radius: 20px;
padding: 40px;
box-shadow: var(--shadow);
text-align: center;
}
.animated-characters {
display: flex;
justify-content: center;
gap: 15px;
flex-wrap: wrap;
margin-top: 30px;
}
.char-box {
width: 80px;
height: 80px;
background: var(--primary-color);
border-radius: 15px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 2rem;
font-weight: 700;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
}
.char-box:hover {
background: var(--accent-color);
transform: rotate(360deg) scale(1.2);
}
.char-box::after {
content: attr(data-pinyin);
position: absolute;
bottom: -25px;
font-size: 0.8rem;
color: var(--text-secondary);
opacity: 0;
transition: opacity 0.3s ease;
}
.char-box:hover::after {
opacity: 1;
}
.wave-animation {
animation: wave 2s ease-in-out infinite;
}
@keyframes wave {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
.pulse-animation {
animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
0% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
}
70% {
transform: scale(1.05);
box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
}
100% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
}
}
.stats-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-top: 40px;
}
.stat-card {
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 25px;
text-align: center;
color: white;
border: 1px solid rgba(255, 255, 255, 0.3);
transition: all 0.3s ease;
}
.stat-card:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-5px);
}
.stat-number {
font-size: 2.5rem;
font-weight: 800;
margin-bottom: 5px;
}
.stat-label {
font-size: 1rem;
opacity: 0.9;
}
.floating-emoji {
position: fixed;
font-size: 2rem;
pointer-events: none;
animation: float 4s ease-in-out infinite;
z-index: 1000;
}
@keyframes float {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0.8;
}
50% {
transform: translateY(-30px) rotate(180deg);
opacity: 0.4;
}
100% {
transform: translateY(0) rotate(360deg);
opacity: 0.8;
}
}
.footer {
text-align: center;
margin-top: 40px;
color: rgba(255, 255, 255, 0.8);
font-size: 1rem;
}
@media (max-width: 768px) {
.header h1 {
font-size: 2.5rem;
}
.greeting-text {
font-size: 2rem;
}
.input-group {
flex-direction: column;
align-items: center;
}
.name-input {
min-width: 100%;
max-width: 300px;
}
.animated-characters {
gap: 10px;
}
.char-box {
width: 60px;
height: 60px;
font-size: 1.5rem;
}
}
@media (max-width: 480px) {
.main-content {
grid-template-columns: 1fr;
}
.stats-section {
grid-template-columns: repeat(2, 1fr);
}
}
</style>
</head>
<body>
<div class="container">
<header class="header">
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
Built with anycoder
</a>
<h1>你好 👋</h1>
<p>探索世界各地的温暖问候</p>
</header>
<main class="main-content">
<div class="greeting-card" onclick="playGreeting('你好', 'zh-CN')">
<div class="greeting-text">你好</div>
<div class="language-name">中文 (Chinese)</div>
<div class="pronunciation">Nǐ hǎo</div>
</div>
<div class="greeting-card" onclick="playGreeting('Hello', 'en-US')">
<div class="greeting-text">Hello</div>
<div class="language-name">英语 (English)</div>
<div class="pronunciation">/həˈloʊ/</div>
</div>
<div class="greeting-card" onclick="playGreeting('Bonjour', 'fr-FR')">
<div class="greeting-text">Bonjour</div>
<div class="language-name">法语 (French)</div>
<div class="pronunciation">/bɔ̃.ʒuʁ/</div>
</div>
<div class="greeting-card" onclick="playGreeting('Hola', 'es-ES')">
<div class="greeting-text">Hola</div>
<div class="language-name">西班牙语 (Spanish)</div>
<div class="pronunciation">/ˈo.la/</div>
</div>
<div class="greeting-card" onclick="playGreeting('Konnichiwa', 'ja-JP')">
<div class="greeting-text">こんにちは</div>
<div class="language-name">日语 (Japanese)</div>
<div class="pronunciation">Konnichiwa</div>
</div>
<div class="greeting-card" onclick="playGreeting('Annyeonghaseyo', 'ko-KR')">
<div class="greeting-text">안녕하세요</div>
<div class="language-name">韩语 (Korean)</div>
<div class="pronunciation">Annyeonghaseyo</div>
</div>
<div class="greeting-card" onclick="playGreeting('Guten Tag', 'de-DE')">
<div class="greeting-text">Guten Tag</div>
<div class="language-name">德语 (German)</div>
<div class="pronunciation">/ˈɡuːtn̩ taːk/</div>
</div>
<div class="greeting-card" onclick="playGreeting('Ciao', 'it-IT')">
<div class="greeting-text">Ciao</div>
<div class="language-name">意大利语 (Italian)</div>
<div class="pronunciation">/ˈtʃa.o/</div>
</div>
<div class="greeting-card" onclick="playGreeting('Salam', 'ar-SA')">
<div class="greeting-text">سلام</div>
<div class="language-name">阿拉伯语 (Arabic)</div>
<div class="pronunciation">/saˈlaːm/</div>
</div>
</main>
<section class="interactive-section">
<h2>个性化问候生成器</h2>
<div class="input-group">
<input type="text" class="name-input" id="nameInput" placeholder="请输入您的名字..." maxlength="20">
<button class="generate-btn" onclick="generatePersonalizedGreeting()">生成问候</button>
</div>
<div class="custom-greeting" id="customGreeting"></div>
</section>
<section class="animation-section">
<h2>点击汉字体验动画</h2>
<div class="animated-characters">
<div class="char-box wave-animation" data-pinyin="nǐ" onclick="animateCharacter(this)">你</div>
<div class="char-box pulse-animation" data-pinyin="hǎo" onclick="animateCharacter(this)">好</div>
<div class="char-box" data-pinyin="shì" onclick="animateCharacter(this)">世</div>
<div class="char-box" data-pinyin="jiè" onclick="animateCharacter(this)">界</div>
</div>
</section>
<section class="stats-section">
<div class="stat-card">
<div class="stat-number" id="greetingCount">0</div>
<div class="stat-label">问候次数</div>
</div>
<div class="stat-card">
<div class="stat-number" id="languageCount">9</div>
<div class="stat-label">支持语言</div>
</div>
<div class="stat-card">
<div class="stat-number" id="characterCount">4</div>
<div class="stat-label">汉字动画</div>
</div>
<div class="stat-card">
<div class="stat-number" id="happyUsers">∞</div>
<div class="stat-label">快乐用户</div>
</div>
</section>
<footer class="footer">
<p>用问候连接世界 💝 | 每一个"你好"都是温暖的开始</p>
</footer>
</div>
<script>
// 初始化统计数据
let greetingCounter = 0;
let clickCount = 0;
// 从localStorage加载数据
window.addEventListener('load', () => {
const savedCount = localStorage.getItem('greetingCount');
if (savedCount) {
greetingCounter = parseInt(savedCount);
updateStats();
}
// 添加随机浮动表情
createFloatingEmoji();
setInterval(createFloatingEmoji, 5000);
});
// 播放问候语音
function playGreeting(text, lang) {
// 增加计数
greetingCounter++;
localStorage.setItem('greetingCount', greetingCounter);
updateStats();
// 创建语音合成
if ('speechSynthesis' in window) {
const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = lang;
utterance.rate = 0.9;
utterance.pitch = 1.1;
speechSynthesis.speak(utterance);
}
// 显示点击效果
showClickEffect();
// 显示提示
showNotification(`正在播放: ${text}`);
}
// 生成个性化问候
function generatePersonalizedGreeting() {
const name = document.getElementById('nameInput').value.trim();
const greetingElement = document.getElementById('customGreeting');
if (!name) {
showNotification('请输入您的名字!', 'warning');
return;
}
const greetings = [
`你好,${name}!很高兴认识你!`,
`Hello, ${name}! Nice to meet you!`,
`Bonjour, ${name}! Enchanté!`,
`Hola, ${name}! Mucho gusto!`,
`こんにちは、${name}さん!はじめまして!`,
`안녕하세요, ${name}님! 만나서 반갑습니다!`
];
const randomGreeting = greetings[Math.floor(Math.random() * greetings.length)];
greetingElement.textContent = randomGreeting;
greetingElement.classList.add('show');
// 播放语音
if ('speechSynthesis' in window) {
const utterance = new SpeechSynthesisUtterance(randomGreeting);
utterance.lang = randomGreeting.includes('你好') ? 'zh-CN' : 'en-US';
utterance.rate = 0.9;
speechSynthesis.speak(utterance);
}
// 添加动画效果
greetingElement.style.animation = 'none';
setTimeout(() => {
greetingElement.style.animation = 'pulse 0.5s ease-in-out';
}, 10);
// 清空输入框
setTimeout(() => {
document.getElementById('nameInput').value = '';
}, 1000);
}
// 动画效果
function animateCharacter(element) {
clickCount++;
// 添加旋转动画
element.style.animation = 'none';
setTimeout(() => {
element.style.animation = 'spin 0.6s ease-in-out';
}, 10);
// 创建粒子效果
createParticles(element);
// 显示点击次数
if (clickCount % 5 === 0) {
showNotification(`太棒了!你已经点击了 ${clickCount} 次!`, 'success');
}
}
// 创建粒子效果
function createParticles(element) {
const rect = element.getBoundingClientRect();
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
for (let i = 0; i < 8; i++) {
const particle = document.createElement('div');
particle.style.cssText = `
position: fixed;
width: 6px;
height: 6px;
background: ${['#6366f1', '#ec4899', '#8b5cf6', '#f59e0b'][Math.floor(Math.random() * 4)]};
border-radius: 50%;
left: ${centerX}px;
top: ${centerY}px;
pointer-events: none;
z-index: 9999;
`;
document.body.appendChild(particle);
const angle = (i / 8) * Math.PI * 2;
const distance = 50 + Math.random() * 30;
const duration = 800 + Math.random() * 400;
particle.animate([
{
transform: 'translate(0, 0) scale(1)',
opacity: 1
},
{
transform: `translate(${Math.cos(angle) * distance}px, ${Math.sin(angle) * distance}px) scale(0)`,
opacity: 0
}
], {
duration: duration,
easing: 'ease-out'
}).onfinish = () => particle.remove();
}
}
// 创建浮动表情
function createFloatingEmoji() {
const emojis = ['😊', '❤️', '✨', '🌟', '💖', '🎉', '🌈', '💫'];
const emoji = document.createElement('div');
emoji.className = 'floating-emoji';
emoji.textContent = emojis[Math.floor(Math.random() * emojis.length)];
emoji.style.left = Math.random() * window.innerWidth + 'px';
emoji.style.top = window.innerHeight + 'px';
emoji.style.animationDuration = (3 + Math.random() * 2) + 's';
document.body.appendChild(emoji);
setTimeout(() => emoji.remove(), 5000);
}
// 显示点击效果
function showClickEffect() {
const effect = document.createElement('div');
effect.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
border: 3px solid rgba(255, 255, 255, 0.8);
border-radius: 50%;
transform: translate(-50%, -50%) scale(0);
pointer-events: none;
z-index: 9999;
`;
document.body.appendChild(effect);
effect.animate([
{ transform: 'translate(-50%, -50%) scale(0)', opacity: 1 },
{ transform: 'translate(-50%, -50%) scale(2)', opacity: 0 }
], {
duration: 600,
easing: 'ease-out'
}).onfinish = () => effect.remove();
}
// 显示通知
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
const colors = {
info: 'rgba(99, 102, 241, 0.9)',
success: 'rgba(16, 185, 129, 0.9)',
warning: 'rgba(245, 158, 11, 0.9)'
};
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: ${colors[type]};
color: white;
padding: 15px 25px;
border-radius: 10px;
font-weight: 500;
z-index: 10000;
transform: translateX(100%);
transition: transform 0.3s ease;
backdrop-filter: blur(10px);
box-shadow: var(--shadow);
`;
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => notification.style.transform = 'translateX(0)', 100);
setTimeout(() => {
notification.style.transform = 'translateX(100%)';
setTimeout(() => notification.remove(), 300);
}, 3000);
}
// 更新统计数据
function updateStats() {
const countElement = document.getElementById('greetingCount');
countElement.textContent = greetingCounter;
// 添加数字动画
countElement.style.transform = 'scale(1.2)';
countElement.style.color = '#ec4899';
setTimeout(() => {
countElement.style.transform = 'scale(1)';
countElement.style.color = 'white';
}, 300);
}
// 键盘事件监听
document.getElementById('nameInput').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
generatePersonalizedGreeting();
}
});
// 添加CSS动画关键帧
const style = document.createElement('style');
style.textContent = `
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
`;
document.head.appendChild(style);
// 页面可见性变化时的处理
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
speechSynthesis.cancel();
}
});
// 随机背景动画
setInterval(() => {
const cards = document.querySelectorAll('.greeting-card');
const randomCard = cards[Math.floor(Math.random() * cards.length)];
randomCard.style.transform = 'scale(1.05)';
setTimeout(() => {
randomCard.style.transform = '';
}, 200);
}, 5000);
</script>
</body>
</html> |