From 2d68570465cfdce5b267c7d016368707f767ef12 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 28 Sep 2026 11:09:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E4=BD=9C=E5=93=81=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8=E6=94=B9=E4=B8=A4?= =?UTF-8?q?=E5=88=97=E2=80=94=E2=80=94=E4=BD=9C=E8=80=85=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=97=E3=80=81=E5=86=85=E5=AE=B9=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=8D=A2=E8=A1=8C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/creator/WorksGallery.tsx | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) 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: '暂无评论。' }} />