import { useState, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { Row, Col, Card, Typography, Tag, Skeleton, Empty, Space } from 'antd' import { FireOutlined, ClockCircleOutlined, VideoCameraOutlined } from '@ant-design/icons' import { fetchStreams, type StreamInfo } from '../../api/streams' const { Title, Text } = Typography const statusMeta: Record = { live: { color: 'red', label: '直播中', icon: }, pending: { color: 'blue', label: '待开播', icon: }, ended: { color: 'default', label: '已结束', icon: null }, cancelled: { color: 'default', label: '已取消', icon: null }, } export default function HomePage() { const [streams, setStreams] = useState([]) const [loading, setLoading] = useState(true) const navigate = useNavigate() useEffect(() => { fetchStreams().then(setStreams).catch(() => {}).finally(() => setLoading(false)) }, []) const sorted = [...streams].sort((a, b) => { const order: Record = { live: 0, pending: 1, ended: 2, cancelled: 3 } return (order[a.status] ?? 9) - (order[b.status] ?? 9) }) return (
StreamCore 企业级直播平台
直播频道 {loading ? ( {[1,2,3,4,5,6].map(i => ( ))} ) : sorted.length === 0 ? ( ) : ( {sorted.map(s => { const meta = statusMeta[s.status] ?? statusMeta.pending return ( {!s.cover_url && ( )}
{meta.icon} {meta.label}
} bodyStyle={{ padding: '16px 20px' }} onClick={() => navigate(`/watch/${s.id}`)} > {s.title}} description={{s.description || '暂无简介'}} /> ) })} )}
) }