'use client'; import Link from 'next/link'; import { useState, useEffect } from 'react'; import { HomePageClient } from './home-client'; import { ArrowRight, Sparkles, BookOpen, Bot, Compass, Zap } from 'lucide-react'; import { useT } from '@/i18n'; import { API_BASE } from '@/lib/config'; export default function HomePage() { const t = useT(); const [courses, setCourses] = useState([]); useEffect(() => { fetch(`${API_BASE}/courses?pageSize=3`) .then(r => r.json()).then(data => setCourses(data.items || [])) .catch(() => {}); }, []); const stats = [ { value: '50+', label: t.home.statTopics }, { value: '200+', label: t.home.statPrompts }, { value: '30+', label: t.home.statTools }, { value: '10,000+', label: t.home.statExplorers }, ]; const features = [ { icon: Compass, title: t.home.featureGuide, desc: t.home.featureGuideDesc }, { icon: Bot, title: t.home.featureSandbox, desc: t.home.featureSandboxDesc }, { icon: BookOpen, title: t.home.featurePrompts, desc: t.home.featurePromptsDesc }, { icon: Zap, title: t.home.featureUpdate, desc: t.home.featureUpdateDesc }, ]; return ( {/* Hero */}
{t.home.badge}

{t.home.heroHighlight}
{t.home.heroRest}

{t.home.desc}

{t.home.startExplore} {t.home.freeRegister}
{/* Stats */}
{stats.map((s) => (
{s.value}
{s.label}
))}
{/* Features */}

{t.home.whyTitle}

{t.home.whyDesc}

{features.map((feat) => (

{feat.title}

{feat.desc}

))}
{/* Popular Courses */}

{t.home.popularTopics}

{t.home.popularDesc}

{t.common.viewAll}
{courses.length > 0 ? courses.map((course: any) => (
{course.isFree ? t.courses.free : t.courses.paid}

{course.title}

{course.description || ''}

)) : ( <> {[{ title: 'AI 通识:零基础入门', tag: t.courses.free }, { title: '提示词工程从入门到精通', tag: '热门' }, { title: '用 AI 提升 10 倍办公效率', tag: '推荐' }].map((course) => (
{course.tag}

{course.title}

探索 AI 世界

))} )}
{/* CTA */}

{t.home.ctaTitle}

{t.home.ctaDesc}

{t.home.freeRegister}
); }