import { useState, useEffect } from 'react' import { Row, Col, Card, Statistic, Typography, Table, Tag, Space } from 'antd' import { VideoCameraOutlined, EyeOutlined, SignalFilled } from '@ant-design/icons' import { fetchStreams, type StreamInfo } from '../../api/streams' const { Title } = Typography export default function Dashboard() { const [streams, setStreams] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { loadData() const timer = setInterval(loadData, 10000) return () => clearInterval(timer) }, []) async function loadData() { try { const data = await fetchStreams() setStreams(data) } catch { /* ignore */ } setLoading(false) } const liveCount = streams.filter((s) => s.status === 'live').length const pendingCount = streams.filter((s) => s.status === 'pending').length const statusMap: Record = { pending: { color: 'blue', label: '待开播' }, live: { color: 'green', label: '直播中' }, ended: { color: 'default', label: '已结束' }, cancelled: { color: 'red', label: '已取消' }, } const recentColumns = [ { title: '标题', dataIndex: 'title', key: 'title', ellipsis: true }, { title: '状态', dataIndex: 'status', key: 'status', render: (status: string) => { const s = statusMap[status] || { color: 'default', label: status } return {s.label} }, }, { title: '创建时间', dataIndex: 'created_at', key: 'created_at', render: (v: string) => v?.slice(0, 16) }, ] return (
概览 } loading={loading} /> } loading={loading} /> } loading={loading} /> ) }