'use client'; import Link from 'next/link'; import { useState, useEffect } from 'react'; import { HomePageClient } from './home-client'; import { ArrowRight, Sparkles, BookOpen, Bot, Wrench, GraduationCap, FileText, Puzzle, MessageSquare, Code, BarChart3 } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Card } from '@/components/ui/card'; import { useT } from '@/i18n'; import { API_BASE } from '@/lib/config'; export default function HomePage() { const t = useT(); const [courses, setCourses] = useState([]); const [featuredTools, setFeaturedTools] = useState([]); const [stats, setStats] = useState<{ tools: number; courses: number; prompts: number; practices: number } | null>(null); useEffect(() => { Promise.all([ fetch(`${API_BASE}/tools?isFeatured=true&pageSize=6&categoryId=7`).then(r => r.json()), fetch(`${API_BASE}/courses?pageSize=3`).then(r => r.json()), fetch(`${API_BASE}/tools?pageSize=1`).then(r => r.json()), fetch(`${API_BASE}/prompts?pageSize=1`).then(r => r.json()), fetch(`${API_BASE}/practices?pageSize=1`).then(r => r.json()), ]).then(([toolsData, coursesData, toolsAll, promptsData, practicesData]) => { setFeaturedTools(toolsData.items || []); setCourses(coursesData.items || []); setStats({ tools: toolsAll.total || toolsAll.items?.length || 0, courses: coursesData.total || coursesData.items?.length || 0, prompts: promptsData.total || promptsData.items?.length || 0, practices: practicesData.total || practicesData.items?.length || 0, }); }).catch(() => { setStats({ tools: 0, courses: 0, prompts: 0, practices: 0 }); }); }, []); const statItems = [ { value: stats ? `${stats.tools}+` : '--', label: '收录工具', href: '/tools', icon: Wrench }, { value: stats ? `${stats.courses}+` : '--', label: '课程资源', href: '/courses', icon: BookOpen }, { value: stats ? `${stats.prompts}+` : '--', label: '提示词库', href: '/prompts', icon: FileText }, { value: stats ? `${stats.practices}+` : '--', label: '练习场景', href: '/practices', icon: Puzzle }, ]; return ( {/* Hero */}
精选AI工具 · 真实评测

找AI工具?先看真实评测

汇集优质AI工具,提供真实使用评测、详细参数对比和专业教程。帮你快速找到合适工具,系统化提升AI应用能力。

浏览工具库 沙盒体验
{/* Stats */}
{statItems.map((s) => (
{s.value}
{s.label}
))}
{/* Featured Tools */} {featuredTools.length > 0 && (

精选AI工具推荐

每个工具都经过实际测试,附带详细评测,助你快速决策

查看全部
{featuredTools.map((tool: any) => { const highlightMatch = tool.description?.match(/【推荐理由】\s*(.+?)(?:\n|$)/); const baseDesc = tool.description?.split('\n\n')[0] || ''; return (

{tool.name}

{baseDesc}

{highlightMatch && (

💡 {highlightMatch[1].trim().slice(0, 35)}

)} {tool.tags && (
{tool.tags.split(',').slice(0, 3).map((tag: string) => ( {tag.trim()} ))}
)}
); })}
)} {/* Marketplace Skills Section */}

💼 AI 技能广场

即用即走的 AI 工作流技能,解决具体业务问题,¥9.9 起

查看全部技能

标题大师

AI 生成高点击标题

¥9.9 已售1000+
📋

提案智造

5个问题生成专业商业提案

¥19.9 6个技能可选
⚖️

合同审查助手

AI 标记风险条款并给出修改建议

¥29.9 专业级
{/* AI 能力导览 */}

AI 能力导览

探索 AI 能为你做什么,从对话写作到编程实战,找到适合你的场景

{[ { icon: MessageSquare, title: '对话写作', desc: '与 AI 进行自然对话,获取灵感、润色文案、翻译语言', href: '/sandbox', cta: '打开沙盒' }, { icon: Code, title: '编程辅助', desc: '生成代码、调试错误、解释算法,你的随身编程搭档', href: '/sandbox', cta: '打开沙盒' }, { icon: BarChart3, title: '数据分析', desc: '分析数据、生成图表、洞察趋势,让数据说话', href: '/sandbox', cta: '打开沙盒' }, { icon: FileText, title: '提示词工程', desc: '学习编写高效提示词,掌握与 AI 沟通的最佳实践', href: '/prompts', cta: '浏览提示词库' }, { icon: GraduationCap, title: '技能实战', desc: '在真实场景中练习 AI 技能,获得即时评分反馈', href: '/practices', cta: '开始练习' }, { icon: Puzzle, title: '工作流技能', desc: '免费使用的 AI 工作流技能,解决具体业务问题', href: '/marketplace', cta: '前往技能广场' }, ].map((item) => { const Icon = item.icon; return (

{item.title}

{item.desc}

{item.cta} → ); })}
{/* 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 || ''}

)) : (
{t.common.loading}
)}
{/* CTA */}

{t.home.ctaTitle}

{t.home.ctaDesc}

{t.home.freeRegister}
); }