全站汉化 + antd zhCN locale
This commit is contained in:
1 parent
2e4594fa77
commit
b96323eb99
9 files changed
+134
-136
No files matched your search
@@ -9,10 +9,10 @@ import { fetchStreams, deleteStream, goLive, endStream, type StreamInfo } from '
|
||||
const { Title, Text } = Typography
|
||||
|
||||
const statusMap: Record<string, { color: string; label: string }> = {
|
||||
pending: { color: 'blue', label: 'Pending' },
|
||||
live: { color: 'green', label: 'Live' },
|
||||
ended: { color: 'default', label: 'Ended' },
|
||||
cancelled: { color: 'red', label: 'Cancelled' },
|
||||
pending: { color: 'blue', label: '待开播' },
|
||||
live: { color: 'green', label: '直播中' },
|
||||
ended: { color: 'default', label: '已结束' },
|
||||
cancelled: { color: 'red', label: '已取消' },
|
||||
}
|
||||
|
||||
export default function StreamList() {
|
||||
@@ -27,47 +27,47 @@ export default function StreamList() {
|
||||
try {
|
||||
const data = await fetchStreams()
|
||||
setStreams(data)
|
||||
} catch { message.error('Failed to load streams') }
|
||||
} catch { message.error('加载失败') }
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
try {
|
||||
await deleteStream(id)
|
||||
message.success('Stream deleted')
|
||||
message.success('已删除')
|
||||
loadData()
|
||||
} catch { message.error('Delete failed') }
|
||||
} catch { message.error('删除失败') }
|
||||
}
|
||||
|
||||
async function handleGoLive(id: number) {
|
||||
try {
|
||||
await goLive(id)
|
||||
message.success('Stream is now live')
|
||||
message.success('已设置为直播中')
|
||||
loadData()
|
||||
} catch { message.error('Failed to set live') }
|
||||
} catch { message.error('操作失败') }
|
||||
}
|
||||
|
||||
async function handleEnd(id: number) {
|
||||
try {
|
||||
await endStream(id)
|
||||
message.success('Stream ended')
|
||||
message.success('已结束直播')
|
||||
loadData()
|
||||
} catch { message.error('Failed to end') }
|
||||
} catch { message.error('操作失败') }
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', key: 'id', width: 80 },
|
||||
{ title: 'Title', dataIndex: 'title', key: 'title', ellipsis: true },
|
||||
{ title: '标题', dataIndex: 'title', key: 'title', ellipsis: true },
|
||||
{
|
||||
title: 'Status', dataIndex: 'status', key: 'status', width: 110,
|
||||
title: '状态', dataIndex: 'status', key: 'status', width: 100,
|
||||
render: (s: string) => {
|
||||
const info = statusMap[s] || { color: 'default', label: s }
|
||||
return <Tag color={info.color}>{info.label}</Tag>
|
||||
},
|
||||
},
|
||||
{ title: 'Created', dataIndex: 'created_at', key: 'created_at', render: (v: string) => v?.slice(0, 16), width: 170 },
|
||||
{ title: '创建时间', dataIndex: 'created_at', key: 'created_at', render: (v: string) => v?.slice(0, 16), width: 170 },
|
||||
{
|
||||
title: 'Actions', key: 'actions', width: 280,
|
||||
title: '操作', key: 'actions', width: 280,
|
||||
render: (_: any, record: StreamInfo) => (
|
||||
<Space size="small">
|
||||
<Button
|
||||
@@ -75,26 +75,26 @@ export default function StreamList() {
|
||||
icon={<LinkOutlined />}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(record.stream_key)
|
||||
message.success('Stream key copied')
|
||||
message.success('推流码已复制')
|
||||
}}
|
||||
>
|
||||
Copy Key
|
||||
复制推流码
|
||||
</Button>
|
||||
{record.status !== 'live' ? (
|
||||
<Tooltip title="Mark as live">
|
||||
<Tooltip title="切换为直播中">
|
||||
<Button size="small" type="primary" icon={<PlayCircleOutlined />}
|
||||
onClick={() => handleGoLive(record.id)} ghost />
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip title="End stream">
|
||||
<Tooltip title="结束直播">
|
||||
<Button size="small" icon={<StopOutlined />}
|
||||
onClick={() => handleEnd(record.id)} danger />
|
||||
</Tooltip>
|
||||
)}
|
||||
<Button size="small" onClick={() => window.open(`/watch/${record.id}`, '_blank')}>
|
||||
Watch
|
||||
观看
|
||||
</Button>
|
||||
<Popconfirm title="Delete this stream?" onConfirm={() => handleDelete(record.id)}>
|
||||
<Popconfirm title="确定删除这条直播?" onConfirm={() => handleDelete(record.id)}>
|
||||
<Button size="small" icon={<DeleteOutlined />} danger />
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
@@ -105,9 +105,9 @@ export default function StreamList() {
|
||||
return (
|
||||
<div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
|
||||
<Title level={3} style={{ margin: 0 }}>Streams</Title>
|
||||
<Title level={3} style={{ margin: 0 }}>直播列表</Title>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={() => navigate('/admin/streams/new')}>
|
||||
New Stream
|
||||
创建直播
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
|
||||
Reference in new issue
Block a user