diff --git a/web/src/components/creator/WorksGallery.tsx b/web/src/components/creator/WorksGallery.tsx index ff534e2..3887bef 100644 --- a/web/src/components/creator/WorksGallery.tsx +++ b/web/src/components/creator/WorksGallery.tsx @@ -69,6 +69,7 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG const [metricsPending, setMetricsPending] = useState(false); const [comments, setComments] = useState([]); 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) => ( + + {record.author_name || '—'} + + {record.published_at ? dateTime(record.published_at) : '—'} + + + ), + }, + { title: '内容', dataIndex: 'content' }, ]} locale={{ emptyText: '暂无评论。' }} />