From b8b7da975d81afdd9c414734b6b9827ba8523964 Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Wed, 25 Nov 2026 08:59:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20390=20=E6=A1=A3=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E6=A8=AA=E5=90=91=E6=BB=9A=E5=8A=A8=EF=BC=88?= =?UTF-8?q?DEF-04=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 两个列表页的表格是 `w-full`,在 356px 容器里 7 列被压成逐字竖排; 外层虽有 `overflow-x-auto`,但表格自身没有最小宽度 ⇒ **没有东西可滚**, 于是「溢出容器」变成了「挤扁内容」。sweep 的 clipping 检测为 0 (单元格没有 overflow:hidden),这个缺陷只能靠截图发现。 改法:`min-w-[760px]` 让列宽由内容撑开,关键列(标题/Slug/状态/更新时间、 用户名/昵称/邮箱/角色/状态/创建时间)加 `whitespace-nowrap`。 复现口径:`scrollWidth 760 > clientWidth 356`。 判别性测试:断言 table 带 `min-w-[760px]`、其父级带 `overflow-x-auto`; 去掉 min-w ⇒ 转红。 --- .../admin/content/[modelCode]/page.test.tsx | 16 ++++++++++++++ src/app/admin/content/[modelCode]/page.tsx | 20 ++++++++--------- src/app/admin/users/page.tsx | 22 +++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/app/admin/content/[modelCode]/page.test.tsx b/src/app/admin/content/[modelCode]/page.test.tsx index c4fefc75..5aabca73 100644 --- a/src/app/admin/content/[modelCode]/page.test.tsx +++ b/src/app/admin/content/[modelCode]/page.test.tsx @@ -151,4 +151,20 @@ describe('内容列表页:搜索请求节流', () => { expect(screen.getByText('新查询结果')).toBeInTheDocument(); expect(screen.queryByText('慢查询结果')).toBeNull(); }); + + // ── DEF-04:390 档表格必须能横向滚动,而不是把 7 列挤成一条 ── + it('表格带最小宽度并被 overflow-x-auto 容器包住(390 档可横滚)', async () => { + nav.state.params = { modelCode: 'news' }; + api.getItems.mockResolvedValue(rowsResult([row('一条内容')])); + const { container } = render(); + await waitFor(() => expect(screen.getByText('一条内容')).toBeInTheDocument()); + + const table = container.querySelector('table'); + expect(table).not.toBeNull(); + // 固定版式宽:列宽由 white-space:nowrap 撑开,容器才有东西可滚 + expect(table!.className).toContain('min-w-[760px]'); + // 外层必须真的允许横向滚动,否则 min-w 只是把内容溢出成裁剪 + const scroller = table!.parentElement; + expect(scroller!.className).toContain('overflow-x-auto'); + }); }); diff --git a/src/app/admin/content/[modelCode]/page.tsx b/src/app/admin/content/[modelCode]/page.tsx index 779b7f40..aa7c866e 100644 --- a/src/app/admin/content/[modelCode]/page.tsx +++ b/src/app/admin/content/[modelCode]/page.tsx @@ -177,14 +177,14 @@ export default function ContentListPage() { {/* Table */}
- +
- - - - - + + + + + @@ -205,15 +205,15 @@ export default function ContentListPage() { ) : ( items.map((item) => ( - - - -
标题Slug状态更新时间操作标题Slug状态更新时间操作
+ {item.title} + {item.slug || '-'} + + {item.updatedAt ? new Date(item.updatedAt).toLocaleDateString('zh-CN') : '-'} diff --git a/src/app/admin/users/page.tsx b/src/app/admin/users/page.tsx index 58846dcc..2f3e59c3 100644 --- a/src/app/admin/users/page.tsx +++ b/src/app/admin/users/page.tsx @@ -287,16 +287,16 @@ export default function UsersPage() { {/* Users table */}
- +
- - - - - - - + + + + + + + @@ -318,14 +318,14 @@ export default function UsersPage() { ) : ( users.map((u) => ( - - - +
用户名昵称邮箱角色状态创建时间操作用户名昵称邮箱角色状态创建时间操作
+
{u.username}
{u.nickname || '-'} + {u.nickname || '-'} {u.email ? (