feat: 操作审计描述拆为独立列(置于资源/路径与结果之间)

动作列仅保留方法徽标并收窄至 6rem,describeOperation 推导的中文描述
移入新的描述列(宽 10rem,超宽截断),题头与数据行同步调整;
外观回归测试更新为六列结构。
This commit is contained in:
2026-11-21 20:33:58 +08:00
parent 8aae68c95c
commit 7cca63b9d9
2 changed files with 36 additions and 25 deletions
@@ -49,11 +49,12 @@ describe('AuditLogList 页面外观', () => {
expect(rule).toMatch(/border-top:\s*1px\s+solid\s+#eaecf0/)
})
it('列表数据行上方渲染列题头,五个列标签齐全', () => {
it('列表数据行上方渲染列题头,六个列标签齐全', () => {
expect(sfc).toContain('<div class="audit-header">')
expect(sfc).toContain('操作者 / 时间')
expect(sfc).toContain('>动作 / 描述<')
expect(sfc).toContain('>动作<')
expect(sfc).toContain('资源 / 路径')
expect(sfc).toContain('>描述<')
expect(sfc).toContain('>结果<')
expect(sfc).toContain('>IP<')
})
@@ -61,8 +62,9 @@ describe('AuditLogList 页面外观', () => {
it('题头列宽与数据行 VEntityField 的 width 一一对应', () => {
const pairs: Array<[string, string]> = [
['col-username', '12rem'],
['col-method', '10rem'],
['col-method', '6rem'],
['col-resource', '20rem'],
['col-desc', '10rem'],
['col-status', '4rem'],
['col-ip', '9rem'],
]
@@ -88,15 +90,24 @@ describe('AuditLogList 页面外观', () => {
expect(header).toMatch(/border-bottom:\s*1px\s+solid\s+#eaecf0/)
})
it('动作列渲染彩色徽标 + 中文操作描述,结果列徽标经 #title 渲染', () => {
it('动作列渲染彩色徽标,描述独立成列且位于资源/路径与结果之间', () => {
// 组件(@halo-dev/components 2.26.0)在无 title/#title 时不渲染 #extra,
// 原先结果徽标实际不可见;原先方法列 title 与徽标重复渲染同一文案。
// 动作列在徽标后追加 describeOperation 推导的中文描述(登录/新建用户/发布文章等),
// 外层 .action-cell 行内排开并在列宽内截断。
// 描述原先与徽标同行挤在动作列,现拆为独立列(describeOperation 推导的
// 中文描述,如 登录/新建用户/发布文章),题头与数据行均置于资源/路径之后、结果之前。
expect(sfc).not.toContain(':title="log.spec.method"')
expect(sfc).toMatch(/<template #title>\s+<span\s+class="action-cell"/)
expect(sfc).toMatch(/<span\s+class="method-badge"[\s\S]*?<\/span>\s+<span class="action-desc">/)
expect(sfc).not.toContain('action-cell')
expect(sfc).toMatch(/<template #title>\s+<span\s+class="method-badge"/)
expect(sfc).toContain('describeOperation(log.spec)')
expect(sfc).toMatch(/<span class="action-desc">\{\{ describeOperation\(log\.spec\) \}\}<\/span>/)
expect(sfc).toMatch(/<template #title>\s+<span\s+class="status-badge"/)
// 数据行内 resource-text(资源/路径列)在 action-desc(描述列)之前,
// action-desc(描述列)在 status-badge(结果列)之前
const resourceIdx = sfc.indexOf('class="resource-text"')
const descIdx = sfc.indexOf('class="action-desc"')
const statusIdx = sfc.indexOf('class="status-badge"')
expect(resourceIdx).toBeGreaterThan(-1)
expect(descIdx).toBeGreaterThan(resourceIdx)
expect(statusIdx).toBeGreaterThan(descIdx)
})
})