fix(web): 作品统计评论列表改两列——作者时间合并列、内容完整换行显示
This commit is contained in:
@@ -69,6 +69,7 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG
|
||||
const [metricsPending, setMetricsPending] = useState(false);
|
||||
const [comments, setComments] = useState<any[]>([]);
|
||||
const [commentPage, setCommentPage] = useState(1);
|
||||
const [commentPageSize, setCommentPageSize] = useState(10);
|
||||
const [commentTotal, setCommentTotal] = useState(0);
|
||||
const [commentsPending, setCommentsPending] = useState(false);
|
||||
const { message: messageApi } = App.useApp();
|
||||
@@ -98,10 +99,10 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG
|
||||
loadWorks();
|
||||
}, [loadWorks]);
|
||||
|
||||
const loadComments = useCallback(async (workID: string, page: number) => {
|
||||
const loadComments = useCallback(async (workID: string, page: number, pageSize = 10) => {
|
||||
setCommentsPending(true);
|
||||
try {
|
||||
const result = await getList({ resource: 'creator-comments', page, pageSize: 10, filters: { work_id: workID } });
|
||||
const result = await getList({ resource: 'creator-comments', page, pageSize, filters: { work_id: workID } });
|
||||
setComments(result.data);
|
||||
setCommentTotal(result.total);
|
||||
} catch {
|
||||
@@ -266,17 +267,29 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG
|
||||
dataSource={comments}
|
||||
pagination={{
|
||||
current: commentPage,
|
||||
pageSize: 10,
|
||||
pageSize: commentPageSize,
|
||||
total: commentTotal,
|
||||
onChange: (page: number) => {
|
||||
// 受控分页必须同时接住 page 和 pageSize:丢掉 pageSize 会让「条/页」下拉选择后立即回弹。
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
setCommentPage(page);
|
||||
loadComments(detailWork.id, page);
|
||||
setCommentPageSize(pageSize);
|
||||
loadComments(detailWork.id, page, pageSize);
|
||||
},
|
||||
hideOnSinglePage: true }}
|
||||
columns={[
|
||||
{ title: '作者', dataIndex: 'author_name', width: 140, render: (v) => v || '—' },
|
||||
{ title: '内容', dataIndex: 'content', ellipsis: true },
|
||||
{ title: '时间', dataIndex: 'published_at', width: 160, render: (v) => (v ? dateTime(v) : '—') },
|
||||
{
|
||||
title: '作者 / 时间',
|
||||
width: 160,
|
||||
render: (_, record) => (
|
||||
<Flex vertical gap={2}>
|
||||
<Typography.Text>{record.author_name || '—'}</Typography.Text>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{record.published_at ? dateTime(record.published_at) : '—'}
|
||||
</Typography.Text>
|
||||
</Flex>
|
||||
),
|
||||
},
|
||||
{ title: '内容', dataIndex: 'content' },
|
||||
]}
|
||||
locale={{ emptyText: '暂无评论。' }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user