From 891740e0db4d00f9b64022f06fb0820b8be91050 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 7 Aug 2026 21:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5=20/=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=B7=B3=E8=BD=AC=20admin=EF=BC=9B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=AC=E5=BC=80=20HomePage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 3 +- frontend/src/viewer/pages/HomePage.tsx | 126 +++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 frontend/src/viewer/pages/HomePage.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f434378..63854ff 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -10,6 +10,7 @@ import StreamList from './admin/pages/StreamList' import StreamForm from './admin/pages/StreamForm' import NodeManager from './admin/pages/NodeManager' import SettingsPage from './admin/pages/Settings' +import HomePage from './viewer/pages/HomePage' import WatchPage from './viewer/pages/WatchPage' import { verifyToken } from './api/auth' import { getToken } from './api/client' @@ -46,7 +47,7 @@ export default function App() { } /> } /> - } /> + } /> diff --git a/frontend/src/viewer/pages/HomePage.tsx b/frontend/src/viewer/pages/HomePage.tsx new file mode 100644 index 0000000..4974561 --- /dev/null +++ b/frontend/src/viewer/pages/HomePage.tsx @@ -0,0 +1,126 @@ +import { useState, useEffect } from 'react' +import { useNavigate } from 'react-router-dom' +import { + Layout, Row, Col, Card, Typography, Tag, Button, Skeleton, Empty, Space, +} from 'antd' +import { LoginOutlined, FireOutlined, ClockCircleOutlined } from '@ant-design/icons' +import { fetchStreams, type StreamInfo } from '../api/streams' + +const { Header, Content } = Layout +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 ( + +
+ + LiveStream + <Text type="secondary" style={{ fontSize: 14, marginLeft: 10, fontWeight: 400 }}> + 简易直播平台 + </Text> + + +
+ + 全部直播 + + {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 && ( + + {s.status === 'live' ? : '🎬'} + + )} + + } + onClick={() => navigate(`/watch/${s.id}`)} + > + + + {meta.icon} {meta.label} + + {s.title} + + } + description={ + s.description + ? {s.description} + : 暂无简介 + } + /> + + + ) + })} + + )} + +
+ ) +}