/** * Admin 后台 - 仪表盘(报刊风) * * 响应式: 移动端 1 列 → 平板 2 列 → 桌面 4 列 */ import { useEffect, useState } from 'react' import { fetchDashboard, fetchHealth } from '../dal' import type { DashboardStats } from '../types' import { Card, CardBody, CardHeader, StatCard, Alert, SkeletonBlock } from '../components' export default function Dashboard() { const [data, setData] = useState(null) const [health, setHealth] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { let active = true setLoading(true) Promise.all([fetchDashboard(), fetchHealth()]) .then(([stats, h]) => { if (active) { setData(stats) setHealth(h) } }) .catch((err: unknown) => { if (active) setError(err instanceof Error ? err.message : '加载失败') }) .finally(() => { if (active) setLoading(false) }) return () => { active = false } }, []) if (error) { return (
) } const healthText = health?.status === 'healthy' || health?.status === 'ok' ? '正常' : '异常' return (
{/* 统计:报纸数字版式 */}
{/* 联赛列表 */} {loading ? (
{[1, 2, 3, 4].map(i => ( ))}
) : data && data.leagues.length > 0 ? (
{data.leagues.map(l => ( {l.name_zh || l.name} {l.code} ))}
) : (

暂无联赛数据,请先到「数据采集」导入比赛数据。

)}
{/* 快捷操作 */}
) }