"use client" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { useStore } from "@/lib/store" import { Users, BookOpen, ShoppingBag, TrendingUp } from "lucide-react" export default function AdminDashboard() { const { getAllUsers, getAllPurchases } = useStore() const users = getAllUsers() const purchases = getAllPurchases() const totalRevenue = purchases.reduce((sum, p) => sum + p.amount, 0) const totalUsers = users.length const totalPurchases = purchases.length const stats = [ { title: "总用户数", value: totalUsers, icon: Users, color: "text-blue-400", bg: "bg-blue-500/20" }, { title: "总收入", value: `¥${totalRevenue.toFixed(2)}`, icon: TrendingUp, color: "text-[#38bdac]", bg: "bg-[#38bdac]/20", }, { title: "订单数", value: totalPurchases, icon: ShoppingBag, color: "text-purple-400", bg: "bg-purple-500/20" }, { title: "转化率", value: `${totalUsers > 0 ? ((totalPurchases / totalUsers) * 100).toFixed(1) : 0}%`, icon: BookOpen, color: "text-orange-400", bg: "bg-orange-500/20", }, ] return (

数据概览

{stats.map((stat, index) => ( {stat.title}
{stat.value}
))}
最近订单
{purchases .slice(-5) .reverse() .map((p) => (

{p.sectionTitle || "整本购买"}

{new Date(p.createdAt).toLocaleString()}

+¥{p.amount}

{p.paymentMethod || "微信支付"}

))} {purchases.length === 0 &&

暂无订单数据

}
新注册用户
{users .slice(-5) .reverse() .map((u) => (
{u.nickname.charAt(0)}

{u.nickname}

{u.phone}

{new Date(u.createdAt).toLocaleDateString()}

))} {users.length === 0 &&

暂无用户数据

}
) }