feat: 操作审计动作列与详情增加中文操作描述(登录/新建用户/发布文章等)
- utils/audit.ts 新增 describeOperation 纯函数:由 method/resourceType/path 推导中文短语(登录、登出、认证操作、动词+资源中文名、子动作拼接如 发布文章/启用插件、完整短语如修改密码),纯展示层推导,历史记录同样适用 - 列表动作列在徽标后渲染描述(列宽 6rem→10rem),题头改为「动作 / 描述」 - 详情抽屉顶部新增「描述」行 - 新增 utils/audit.spec.ts 10 项用例覆盖全部推导与回退路径, 外观回归测试同步列宽与动作列结构
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from '@halo-dev/components'
|
||||
import type { AuditLog, ListResult } from '@/utils/audit'
|
||||
import {
|
||||
describeOperation,
|
||||
displayUsername,
|
||||
formatTime,
|
||||
isSuccessful,
|
||||
@@ -246,7 +247,7 @@ onMounted(fetchLogs)
|
||||
<div class="audit-header">
|
||||
<div class="header-start">
|
||||
<span class="header-col col-username">操作者 / 时间</span>
|
||||
<span class="header-col col-method">动作</span>
|
||||
<span class="header-col col-method">动作 / 描述</span>
|
||||
<span class="header-col col-resource">资源 / 路径</span>
|
||||
</div>
|
||||
<div class="header-end">
|
||||
@@ -266,11 +267,14 @@ onMounted(fetchLogs)
|
||||
<span class="row-sub">{{ formatTime(log.metadata.creationTimestamp) }}</span>
|
||||
</template>
|
||||
</VEntityField>
|
||||
<!-- 动作列:仅保留彩色徽标(原先 title 与徽标重复渲染两个相同文案) -->
|
||||
<VEntityField width="6rem">
|
||||
<!-- 动作列:彩色徽标 + 该操作实际语义的中文描述(如 登录/新建用户/发布文章) -->
|
||||
<VEntityField width="10rem">
|
||||
<template #title>
|
||||
<span class="method-badge" :class="methodBadgeClass(log.spec.method)">
|
||||
{{ log.spec.method }}
|
||||
<span class="action-cell">
|
||||
<span class="method-badge" :class="methodBadgeClass(log.spec.method)">
|
||||
{{ log.spec.method }}
|
||||
</span>
|
||||
<span class="action-desc">{{ describeOperation(log.spec) }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</VEntityField>
|
||||
@@ -407,7 +411,7 @@ onMounted(fetchLogs)
|
||||
white-space: nowrap;
|
||||
}
|
||||
.col-username { width: 12rem; }
|
||||
.col-method { width: 6rem; }
|
||||
.col-method { width: 10rem; }
|
||||
.col-resource { width: 20rem; }
|
||||
.col-status { width: 4rem; }
|
||||
.col-ip { width: 9rem; }
|
||||
@@ -441,6 +445,20 @@ onMounted(fetchLogs)
|
||||
color: #fff;
|
||||
background: #6b7280;
|
||||
}
|
||||
/* 动作列:徽标 + 描述同行排开,超宽时描述截断(列宽固定 10rem) */
|
||||
.action-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
max-width: 9.75rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
.action-desc {
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.method-post { background: #1e7ee0; }
|
||||
.method-put { background: #d97706; }
|
||||
.method-delete { background: var(--audit-red); }
|
||||
|
||||
Reference in New Issue
Block a user