更新下载次数记录和更新次数记录等

This commit is contained in:
rucky
2026-04-07 18:30:49 +08:00
parent f459cc9ad0
commit 9dc6c0dcce
18 changed files with 665 additions and 591 deletions

View File

@@ -6,7 +6,7 @@ import {
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Package, Download, FileUp, Eye, Users, TrendingUp } from "lucide-react";
import { Package, Download, FileUp, Eye, Users, TrendingUp, Monitor, Wifi } from "lucide-react";
export const dynamic = "force-dynamic";
@@ -24,6 +24,8 @@ export default async function DashboardPage() {
const today = new Date().toISOString().slice(0, 10);
const days = getLast7Days();
const onlineThreshold = new Date(Date.now() - 3 * 60 * 1000);
const [
addonCount,
totalDownloads,
@@ -33,6 +35,9 @@ export default async function DashboardPage() {
totalPV,
todayUV,
pvByDay,
launcherDownloads,
launcherUpdateDownloads,
onlineCount,
] = await Promise.all([
prisma.addon.count(),
prisma.addon.aggregate({ _sum: { totalDownloads: true } }),
@@ -54,6 +59,9 @@ export default async function DashboardPage() {
_count: true,
orderBy: { date: "asc" },
}),
prisma.softwareVersion.aggregate({ _sum: { downloadCount: true } }),
prisma.softwareVersion.aggregate({ _sum: { launcherDownloadCount: true } }),
prisma.launcherOnline.count({ where: { lastSeen: { gte: onlineThreshold } } }),
]);
const pvMap = new Map(pvByDay.map((d) => [d.date, d._count]));
@@ -63,10 +71,17 @@ export default async function DashboardPage() {
}));
const maxPV = Math.max(...chartData.map((d) => d.pv), 1);
const totalSwDownloads = launcherDownloads._sum.downloadCount || 0;
const totalLauncherUpdates = launcherUpdateDownloads._sum.launcherDownloadCount || 0;
const webDownloads = totalSwDownloads - totalLauncherUpdates;
const stats = [
{ title: "插件总数", value: addonCount, icon: Package },
{ title: "总下载量", value: totalDownloads._sum.totalDownloads || 0, icon: Download },
{ title: "插件总下载量", value: totalDownloads._sum.totalDownloads || 0, icon: Download },
{ title: "版本发布数", value: releaseCount, icon: FileUp },
{ title: "启动器下载量 (网页)", value: webDownloads, icon: Monitor },
{ title: "启动器更新量 (客户端)", value: totalLauncherUpdates, icon: Download },
{ title: "启动器在线人数", value: onlineCount, icon: Wifi },
{ title: "今日访问 (PV)", value: todayPV, icon: Eye },
{ title: "今日独立访客 (UV)", value: todayUV, icon: Users },
{ title: "累计访问量", value: totalPV, icon: TrendingUp },
@@ -76,7 +91,7 @@ export default async function DashboardPage() {
<div className="space-y-8">
<h1 className="text-3xl font-bold"></h1>
<div className="grid gap-4 md:grid-cols-3">
<div className="grid gap-4 sm:grid-cols-2 md:grid-cols-3">
{stats.map((stat) => (
<Card key={stat.title}>
<CardHeader className="flex flex-row items-center justify-between pb-2">