全站汉化 + antd zhCN locale

This commit is contained in:
admin committed 2026-08-07 15:04:19 +08:00
1 parent 2e4594fa77
commit b96323eb99
9 files changed
+134 -136

No files matched your search

+14 -26
View File
@@ -41,14 +41,13 @@ export default function WatchPage() {
setActiveQuality(data.qualities[0].label)
}
}
} catch { /* stream not ready */ }
} catch { /* 直播尚未就绪 */ }
setLoading(false)
}
function autoSelectLine(lines: LineInfo[]): LineInfo {
const enabled = lines.filter((l) => l.weight > 0)
if (enabled.length === 0) return lines[0]
const total = enabled.reduce((s, l) => s + l.weight, 0)
let r = Math.random() * total
for (const line of enabled) {
@@ -60,20 +59,13 @@ export default function WatchPage() {
useEffect(() => {
if (!info || !activeLine || !videoRef.current) return
const line = info.lines.find((l) => l.node_id === activeLine)
if (!line) return
const quality = activeQuality
? line.qualities.find((q) => q.label === activeQuality)
: line.qualities[0]
if (!quality) return
if (hls) {
hls.destroy()
}
if (hls) { hls.destroy() }
const url = quality.url
if (Hls.isSupported()) {
const hlsInstance = new Hls({
@@ -87,13 +79,7 @@ export default function WatchPage() {
})
hlsInstance.on(Hls.Events.ERROR, (_event, data) => {
if (data.fatal) {
message.warning('Playback error, trying fallback...')
if (line.unicast_fallback) {
const fbUrl = activeQuality
? line.unicast_fallback.replace('index.m3u8', `${activeQuality}/index.m3u8`)
: line.unicast_fallback
hlsInstance.loadSource(fbUrl)
}
message.warning('播放异常,尝试切换线路...')
}
})
setHls(hlsInstance)
@@ -113,11 +99,13 @@ export default function WatchPage() {
if (!info) {
return (
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#FAF8F5' }}>
<Empty description="Stream not found" />
<Empty description="未找到该直播" />
</div>
)
}
const statusLabel = info.status === 'live' ? '直播中' : info.status === 'pending' ? '待开播' : info.status === 'ended' ? '已结束' : info.status
return (
<Layout style={{ minHeight: '100vh', background: '#1A1A16' }}>
<Header style={{
@@ -132,41 +120,41 @@ export default function WatchPage() {
<Space>
<Button type="text" icon={<ArrowLeftOutlined />} style={{ color: '#fff' }}
onClick={() => window.close()}>
Back
返回
</Button>
<div>
<Title level={5} style={{ color: '#fff', margin: 0 }}>
{info.title}
</Title>
<Tag color={info.status === 'live' ? 'green' : 'default'} style={{ marginLeft: 8 }}>
{info.status === 'live' ? 'LIVE' : info.status}
{statusLabel}
</Tag>
</div>
</Space>
<Space size="middle">
<div style={{ color: '#aaa', fontSize: 13 }}>
<SignalFilled style={{ color: info.multicast_available ? '#52c41a' : '#666', marginRight: 4 }} />
{info.multicast_available ? 'Multicast' : 'Unicast'}
{info.multicast_available ? '组播' : '单播'}
</div>
<Select
value={activeQuality}
onChange={setActiveQuality}
style={{ width: 100 }}
style={{ width: 110 }}
size="small"
options={info.qualities.map((q) => ({ value: q.label, label: q.label }))}
popupMatchSelectWidth={false}
placeholder="清晰度"
/>
<Select
value={activeLine}
onChange={setActiveLine}
style={{ width: 140 }}
style={{ width: 160 }}
size="small"
options={info.lines.map((l) => ({
value: l.node_id,
label: `${l.node_name} (${l.weight})`,
}))}
popupMatchSelectWidth={false}
prefix={<WifiOutlined />}
placeholder="选择线路"
/>
</Space>
</Header>
@@ -196,7 +184,7 @@ export default function WatchPage() {
}}>
<Space direction="vertical" align="center">
<Spin size="large" />
<Text style={{ color: '#fff' }}>Waiting for stream to start...</Text>
<Text style={{ color: '#fff' }}>等待主播开播...</Text>
</Space>
</div>
)}