"use client" import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Loader2 } from "lucide-react" export default function ServerStats() { const [serverStat, setServerStat] = useState<{ timestamp: number } | null>(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { const fetchServerStat = async () => { try { setLoading(true) const response = await fetch("https://api.ninevocalrank.top/basic/v1/ServerStat/info") if (!response.ok) { throw new Error("服务器响应错误") } const data = await response.json() setServerStat(data) } catch (error) { console.error("获取服务器统计信息时出错:", error) setError("无法获取服务器统计信息") } finally { setLoading(false) } } fetchServerStat() }, []) return ( 服务器统计 {loading ? (
) : error ? (

{error}

) : serverStat ? (

最后更新时间: {new Date(serverStat.timestamp * 1000).toLocaleString("zh-CN")}

) : (

暂无数据

)}
) }