"use client" import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Building2, Users, UserCog } from "lucide-react" import { toast } from "sonner" interface DashboardStats { companyCount: number adminCount: number customerCount: number } export default function DashboardPage() { const [stats, setStats] = useState({ companyCount: 0, adminCount: 0, customerCount: 0 }) const [isLoading, setIsLoading] = useState(true) useEffect(() => { const fetchStats = async () => { try { const response = await fetch("http://yishi.com/dashboard/base") const data = await response.json() if (data.code === 200) { setStats(data.data) } else { toast.error(data.msg || "获取统计信息失败") } } catch (error) { toast.error("网络错误,请稍后重试") } finally { setIsLoading(false) } } fetchStats() }, []) return (

仪表盘

项目总数
{isLoading ? "..." : stats.companyCount}
客户总数
{isLoading ? "..." : stats.customerCount}
管理员数量
{isLoading ? "..." : stats.adminCount}
) }