fix: 操作审计题头结果/IP 列与数据列对齐(镜像 entity 行两 td 盒模型)

VEntity 数据行由两个自带 1rem 左右内边距的 td 组成,end 组紧跟 start 组;
题头原先用 margin-left: auto 把结果/IP 推到行尾,与数据列错位 19rem。
现改为题头 start/end 两组各自镜像 1rem 内边距、end 组不再右推。
已用真实 @halo-dev/components CSS + 同构 DOM 在浏览器实测:五列偏差均为 0。
This commit is contained in:
2026-11-21 19:33:54 +08:00
parent 7280ccb5f3
commit 55c50706b5
2 changed files with 18 additions and 8 deletions
@@ -6,7 +6,8 @@ import { describe, expect, it } from 'vitest'
// 操作审计页需保持控制台默认灰底(.audit-page 不自行设置背景色), // 操作审计页需保持控制台默认灰底(.audit-page 不自行设置背景色),
// 筛选栏、数据列表、分页条合并为同一张白色卡片:区块之间不留灰缝, // 筛选栏、数据列表、分页条合并为同一张白色卡片:区块之间不留灰缝,
// 分页条白底随卡片铺满整行、与上方列表左右对齐(与控制台其他列表页观感一致); // 分页条白底随卡片铺满整行、与上方列表左右对齐(与控制台其他列表页观感一致);
// 数据行上方有列题头,题头列宽与数据行各字段固定宽度一一对应; // 数据行上方有列题头,题头列宽与数据行各字段固定宽度一一对应,
// 且题头 start/end 两组各自镜像 entity 行两个 td 的 1rem 左右内边距(end 组紧跟 start 组);
// flex: 1 撑满 main-content 剩余高度,使灰底延伸到页面底部。 // flex: 1 撑满 main-content 剩余高度,使灰底延伸到页面底部。
// 历史上 .audit-page 曾整体铺白导致页面与其他页面观感不一致, // 历史上 .audit-page 曾整体铺白导致页面与其他页面观感不一致,
// 分页条曾左右各留 1rem 导致白底与上方卡片错位, // 分页条曾左右各留 1rem 导致白底与上方卡片错位,
@@ -71,14 +72,19 @@ describe('AuditLogList 页面外观', () => {
} }
}) })
it('题头分组间距与 entity 行一致(start 间距 1rem、end 间距 1.5rem 且右对齐)', () => { it('题头分组间距与 entity 行一致(start 间距 1rem、end 间距 1.5rem 且不右对齐)', () => {
// entity 行由两个自带 1rem 左右内边距的 td 组成,end 组紧跟 start 组(行宽随内容收缩);
// 题头两组各自镜像 1rem 内边距才能与数据列对齐,
// 历史上曾用 margin-left: auto 把结果/IP 推到行尾导致与数据错位 19rem,本测试防止回归。
const start = styleRule('.header-start') const start = styleRule('.header-start')
expect(start).toMatch(/gap:\s*1rem/) expect(start).toMatch(/gap:\s*1rem/)
expect(start).toMatch(/padding:\s*0\s+1rem/)
const end = styleRule('.header-end') const end = styleRule('.header-end')
expect(end).toMatch(/gap:\s*1\.5rem/) expect(end).toMatch(/gap:\s*1\.5rem/)
expect(end).toMatch(/margin-left:\s*auto/) expect(end).toMatch(/padding:\s*0\s+1rem/)
expect(end).not.toMatch(/margin-left:\s*auto/)
const header = styleRule('.audit-header') const header = styleRule('.audit-header')
expect(header).toMatch(/padding:\s*0\.5rem\s+1rem/) expect(header).toMatch(/padding:\s*0\.5rem\s+0/)
expect(header).toMatch(/border-bottom:\s*1px\s+solid\s+#eaecf0/) expect(header).toMatch(/border-bottom:\s*1px\s+solid\s+#eaecf0/)
}) })
@@ -242,7 +242,7 @@ onMounted(fetchLogs)
</template> </template>
</VEmpty> </VEmpty>
<template v-else> <template v-else>
<!-- 列题头:列宽与下方数据行各 VEntityField 的 width 一一对应 --> <!-- 列题头:分组结构与内边距镜像 entity 行的两个 td,列宽与各 VEntityField 的 width 一一对应 -->
<div class="audit-header"> <div class="audit-header">
<div class="header-start"> <div class="header-start">
<span class="header-col col-username">操作者 / 时间</span> <span class="header-col col-username">操作者 / 时间</span>
@@ -381,21 +381,25 @@ onMounted(fetchLogs)
display: flex; display: flex;
gap: 0.5rem; gap: 0.5rem;
} }
/* 列题头:左右内边距与 entity 行(1rem)一致,列宽与数据行字段宽度一一对应 */ /* 列题头:VEntity 数据行由两个 td(entity-start-wrapper / entity-end-wrapper)组成,
每个 td 自带 1rem 左右内边距,end 组紧跟 start 组之后(行宽由内容收缩,不铺满)。
题头按同样结构分两组、各组自带 1rem 内边距,才能与数据列一一对齐;
不可用 margin-left: auto 把 end 组推到行尾(数据行并非如此布局)。 */
.audit-header { .audit-header {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0.5rem 1rem; padding: 0.5rem 0;
border-bottom: 1px solid #eaecf0; border-bottom: 1px solid #eaecf0;
} }
.header-start { .header-start {
display: flex; display: flex;
gap: 1rem; gap: 1rem;
padding: 0 1rem;
} }
.header-end { .header-end {
display: flex; display: flex;
gap: 1.5rem; gap: 1.5rem;
margin-left: auto; padding: 0 1rem;
} }
.header-col { .header-col {
font-size: 0.75rem; font-size: 0.75rem;