feat: 操作审计动作列与详情增加中文操作描述(登录/新建用户/发布文章等)

- utils/audit.ts 新增 describeOperation 纯函数:由 method/resourceType/path
  推导中文短语(登录、登出、认证操作、动词+资源中文名、子动作拼接如
  发布文章/启用插件、完整短语如修改密码),纯展示层推导,历史记录同样适用
- 列表动作列在徽标后渲染描述(列宽 6rem→10rem),题头改为「动作 / 描述」
- 详情抽屉顶部新增「描述」行
- 新增 utils/audit.spec.ts 10 项用例覆盖全部推导与回退路径,
  外观回归测试同步列宽与动作列结构
This commit is contained in:
2026-11-21 20:28:09 +08:00
parent 55c50706b5
commit 8aae68c95c
5 changed files with 273 additions and 10 deletions
@@ -52,7 +52,7 @@ describe('AuditLogList 页面外观', () => {
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('>IP<')
@@ -61,7 +61,7 @@ describe('AuditLogList 页面外观', () => {
it('题头列宽与数据行 VEntityField 的 width 一一对应', () => {
const pairs: Array<[string, string]> = [
['col-username', '12rem'],
['col-method', '6rem'],
['col-method', '10rem'],
['col-resource', '20rem'],
['col-status', '4rem'],
['col-ip', '9rem'],
@@ -88,11 +88,15 @@ describe('AuditLogList 页面外观', () => {
expect(header).toMatch(/border-bottom:\s*1px\s+solid\s+#eaecf0/)
})
it('动作列仅保留彩色徽标、结果列徽标经 #title 渲染', () => {
it('动作列渲染彩色徽标 + 中文操作描述,结果列徽标经 #title 渲染', () => {
// 组件(@halo-dev/components 2.26.0)在无 title/#title 时不渲染 #extra,
// 原先结果徽标实际不可见;原先方法列 title 与徽标重复渲染同一文案。
// 动作列在徽标后追加 describeOperation 推导的中文描述(登录/新建用户/发布文章等),
// 外层 .action-cell 行内排开并在列宽内截断。
expect(sfc).not.toContain(':title="log.spec.method"')
expect(sfc).toMatch(/<template #title>\s+<span\s+class="method-badge"/)
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).toContain('describeOperation(log.spec)')
expect(sfc).toMatch(/<template #title>\s+<span\s+class="status-badge"/)
})
})