From 6958330a5f0819c6d160f35261d9b78df8cc8614 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 28 Sep 2026 12:56:43 +0800 Subject: [PATCH] fix(web): hide title for untitled works --- web/src/components/creator/WorksGallery.tsx | 13 +++++++++---- web/tests/works-gallery-card.test.cjs | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/web/src/components/creator/WorksGallery.tsx b/web/src/components/creator/WorksGallery.tsx index e2a704b..8280ae2 100644 --- a/web/src/components/creator/WorksGallery.tsx +++ b/web/src/components/creator/WorksGallery.tsx @@ -234,9 +234,12 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG
- - {work.title || '无标题'} - + {/* 无标题作品不渲染标题行,避免占位文案增加卡片噪音。 */} + {work.title ? ( + + {work.title} + + ) : null} {work.body ? ( {work.body} @@ -277,7 +280,9 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint }: WorksG {detailWork ? ( ID:{detailWork.work_key || detailWork.id} - {detailWork.title || '无标题'} + {detailWork.title ? ( + {detailWork.title} + ) : null} {detailWork.body || '暂无正文'} diff --git a/web/tests/works-gallery-card.test.cjs b/web/tests/works-gallery-card.test.cjs index 489bd24..4cf3f75 100644 --- a/web/tests/works-gallery-card.test.cjs +++ b/web/tests/works-gallery-card.test.cjs @@ -30,6 +30,13 @@ test('观看/点赞/评论/分享四项指标全宽 GRID 贴封面下方', () => assert.match(body, /borderBottom/); }); +test('无标题作品在卡片和详情中均不显示占位标题', () => { + const text = sourceText(); + assert.match(text, /\{work\.title \? \(/); + assert.match(text, /\{detailWork\.title \? \(/); + assert.doesNotMatch(text, /work\.title \|\| '无标题'|detailWork\.title \|\| '无标题'/); +}); + test('卡片展示作品描述(body 省略两行)', () => { const card = /work\.body \? \(/.exec(sourceText()); assert.ok(card, '卡片应有 body 描述分支');