"use client"; import Link from "next/link"; import { Coins, Flame, Gift, TrendingUp } from "lucide-react"; import type { EconomyStats } from "@/lib/api"; import { postTypeLabel } from "@/lib/postMeta"; import { pointReasonLabel } from "@/lib/points"; import { formatRelative } from "@/lib/format"; import { AdminPageHeader, AdminStatCard } from "@/components/admin"; import { AdminChartCard, DeltaBarChart, NamedBarChart, NamedPieChart, SingleAreaChart, } from "@/components/admin/charts"; const fmt = (n: number) => n.toLocaleString("zh-CN"); function netDeltaLabel(n: number) { if (n > 0) return `+${fmt(n)}`; return fmt(n); } export default function EconomyClient({ stats }: { stats: EconomyStats }) { const checkinSeries = (stats.checkin_series || []).map((d) => ({ date: d.date, count: d.count, })); const ledgerByReason = (stats.ledger_by_reason || []).map((r) => ({ label: pointReasonLabel(r.key || r.label), count: r.count, })); const deltaSeries = stats.delta_series || []; const postsByType = Object.entries(stats.posts_by_type || {}) .map(([t, n]) => ({ label: postTypeLabel(t), count: Number(n) || 0 })) .filter((d) => d.count > 0) .sort((a, b) => b.count - a.count); const net = stats.net_delta_7d ?? 0; return (
} /> } color="var(--clay)" soft="var(--clay-soft)" /> } color="var(--gold)" soft="var(--gold-soft)" /> } color={net >= 0 ? "var(--ok)" : "var(--danger)"} soft={net >= 0 ? "var(--ok-soft)" : "var(--danger-soft)"} />
{checkinSeries.length === 0 ? (

暂无签到数据

) : ( )}
{ledgerByReason.length === 0 ? (

暂无流水

) : ( )}
{deltaSeries.length === 0 ? (

暂无数据

) : ( )}
{postsByType.length === 0 ? (

暂无数据

) : ( )}
最近流水
{(stats.recent_ledger || []).length === 0 ? (

暂无流水

) : (
    {stats.recent_ledger.map((it, idx) => (
  • {pointReasonLabel(it.reason)} {it.note ? ` · ${it.note}` : ""}

    {formatRelative(it.created_at)}

    = 0 ? "var(--accent)" : "var(--danger)" }} > {it.delta >= 0 ? `+${it.delta}` : it.delta}
  • ))}
)}

用户可在{" "} /points {" "} 查看个人流水。

); }