'use client'; import { useState, useEffect, useCallback } from 'react'; import { languages } from '../lib/i18n/config'; import { useTranslation } from '../lib/i18n/useTranslation'; const bannerImages = [ 'https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=1920&h=1080&fit=crop', 'https://images.unsplash.com/photo-1504384308090-c894fdcc538d?w=1920&h=1080&fit=crop', 'https://images.unsplash.com/photo-1519389950473-47ba0277781c?w=1920&h=1080&fit=crop', ]; export default function HomePage({ initialLanguage }: { initialLanguage?: string }) { const { language, t, changeLanguage, getLocalizedPath, isInitialized } = useTranslation(initialLanguage); const [currentSlide, setCurrentSlide] = useState(0); const [isMenuOpen, setIsMenuOpen] = useState(false); // Auto-advance carousel useEffect(() => { const timer = setInterval(() => { setCurrentSlide((prev) => (prev + 1) % t.banner.slides.length); }, 5000); return () => clearInterval(timer); }, [t.banner.slides.length]); // 防抖的语言切换处理 const handleLanguageChange = useCallback( (newLanguage: string) => { changeLanguage(newLanguage as any); }, [changeLanguage], ); // Navigation items const navItems = [ { key: 'home', label: t.nav.home, href: getLocalizedPath('/') }, { key: 'products', label: t.nav.products, href: getLocalizedPath('/products') }, { key: 'news', label: t.nav.news, href: getLocalizedPath('/news') }, { key: 'support', label: t.nav.support, href: getLocalizedPath('/support') }, { key: 'about', label: t.nav.about, href: getLocalizedPath('/about') }, ]; if (!isInitialized) { return (

Loading...

); } return (
{/* Navigation */} {/* Banner Carousel */}
{t.banner.slides.map((slide, index) => (

{slide.title}

{slide.subtitle}

))}
{/* Carousel Indicators */}
{t.banner.slides.map((_, index) => (
{/* Carousel Navigation */}
{/* Features Section */}

{t.features.title}

{t.features.subtitle}

{t.features.items.map((feature, index) => (
{feature.icon}

{feature.title}

{feature.description}

))}
{/* CTA Section */}

{t.cta.title}

{t.cta.subtitle}

{/* Footer */}
); }