"use client"
import { useState, useEffect } from "react"
import { useRouter } from "next/navigation"
import { Search, ChevronRight, BookOpen, Clock, TrendingUp, Users, Home, List, Sparkles, User } from "lucide-react"
import { useStore } from "@/lib/store"
import { bookData, getTotalSectionCount } from "@/lib/book-data"
export default function HomePage() {
const router = useRouter()
const { user } = useStore()
const [mounted, setMounted] = useState(false)
const [searchQuery, setSearchQuery] = useState("")
const totalSections = getTotalSectionCount()
const hasFullBook = user?.hasFullBook || false
const purchasedCount = hasFullBook ? totalSections : user?.purchasedSections?.length || 0
useEffect(() => {
setMounted(true)
}, [])
// 推荐章节
const featuredSections = [
{ id: "1.1", title: "荷包:电动车出租的被动收入模式", tag: "免费", part: "真实的人" },
{ id: "3.1", title: "3000万流水如何跑出来", tag: "热门", part: "真实的行业" },
{ id: "8.1", title: "流量杠杆:抖音、Soul、飞书", tag: "推荐", part: "真实的赚钱" },
]
// 最新更新
const latestSection = {
id: "9.14",
title: "大健康私域:一个月150万的70后",
part: "真实的赚钱",
}
if (!mounted) {
return (
)
}
return (
{/* 顶部区域 */}
{/* Banner卡片 - 最新章节 */}
router.push(`/read/${latestSection.id}`)}
className="relative p-5 rounded-2xl overflow-hidden cursor-pointer"
style={{
background: "linear-gradient(135deg, #0d3331 0%, #1a1a2e 50%, #16213e 100%)",
}}
>
最新更新
{latestSection.title}
{latestSection.part}
开始阅读
{/* 阅读进度卡 */}
我的阅读
{purchasedCount}/{totalSections}章
{totalSections - purchasedCount}
待读
{/* 精选推荐 */}
精选推荐
{featuredSections.map((section) => (
router.push(`/read/${section.id}`)}
className="p-4 rounded-xl bg-[#1c1c1e] border border-white/5 cursor-pointer active:scale-[0.98] transition-transform"
>
{section.id}
{section.tag}
{section.title}
{section.part}
))}
{/* 五篇概览 */}
内容概览
{bookData.slice(0, 4).map((part) => (
router.push("/chapters")}
className="p-4 rounded-xl bg-[#1c1c1e] border border-white/5 cursor-pointer"
>
第{part.number}篇
{part.title}
{part.subtitle}
))}
{/* 数据统计 */}
{/* 序言入口 */}
router.push("/read/preface")}
className="p-4 rounded-xl bg-gradient-to-r from-[#00CED1]/10 to-transparent border border-[#00CED1]/20 cursor-pointer"
>
)
}