From 9b0ae6f4bb674d5653401fe2527cffe0da9cf997 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Wed, 24 Sep 2025 12:12:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=8C=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/console/dashboard/index.tsx | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/web/src/components/console/dashboard/index.tsx b/web/src/components/console/dashboard/index.tsx index da5577b..1ab49c0 100644 --- a/web/src/components/console/dashboard/index.tsx +++ b/web/src/components/console/dashboard/index.tsx @@ -2,10 +2,11 @@ import { getDashboard, DashboardResp } from "@/api/admin" import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Eye, MessageCircle, Newspaper, Users } from "lucide-react" -import { useEffect, useState } from "react" +import { JSX, useEffect, useState } from "react" import { toast } from "sonner" import { path } from "../data" import Link from "next/link" +import { IconType } from "@/types/icon" export function Dashboard() { return ( @@ -16,30 +17,30 @@ export function Dashboard() { } function DataOverview() { - const data = [ + const data: { key: keyof DashboardResp; label: string; icon: IconType; url: string }[] = [ { - "key": "totalPosts", - "label": "Total Posts", - "icon": Newspaper, - "url": path.post + key: "totalPosts", + label: "Total Posts", + icon: Newspaper, + url: path.post }, { - "key": "totalUsers", - "label": "Total Users", - "icon": Users, - "url": path.user + key: "totalUsers", + label: "Total Users", + icon: Users, + url: path.user }, { - "key": "totalComments", - "label": "Total Comments", - "icon": MessageCircle, - "url": path.comment + key: "totalComments", + label: "Total Comments", + icon: MessageCircle, + url: path.comment }, { - "key": "totalViews", - "label": "Total Views", - "icon": Eye, - "url": path.file + key: "totalViews", + label: "Total Views", + icon: Eye, + url: path.file }, ] @@ -63,7 +64,7 @@ function DataOverview() { {item.label} - {(fetchData as any)[item.key]} + {fetchData[item.key]}