import { useState, useEffect } from 'react' import { Row, Col, Statistic, Table, Tag, Typography } from 'antd' import { SignalFilled, ClockCircleOutlined, PlayCircleOutlined } from '@ant-design/icons' import { fetchStreams, type StreamInfo } from '../../api/streams' import { useBrand } from '../../brand/BrandContext' const { Title, Text } = Typography export default function Dashboard() { const { brand } = useBrand() const [streams, setStreams] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { loadData(); const t = setInterval(loadData, 10000); return () => clearInterval(t) }, []) async function loadData() { try { setStreams(await fetchStreams(true)) } catch { /* */ } 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 columns = [ { title: '标题', dataIndex: 'title', key: 'title', ellipsis: true }, { title: '状态', dataIndex: 'status', key: 'status', width: 90, render: (s: string) => {(statusMap[s] || { label: s }).label} }, { title: '创建时间', dataIndex: 'created_at', key: 'created_at', render: (v: string) => v?.slice(0, 16), width: 170 }, ] return (
{brand.brand_name} 管理控制台 · 实时刷新
} />
} />
} />
最近节目 ) }