feat: 操作审计列表增加列题头

- 数据行上方新增题头(操作者/时间、动作、资源/路径、结果、IP),
  各 VEntityField 固定列宽,与题头列一一对应对齐
- 修复动作列 title 与徽标重复渲染同一文案(POST POST)
- 修复结果列状态码徽标不渲染(无 title 时组件不渲染 #extra,
  改经 #title 插槽渲染)
- 追加结构性回归测试锁定题头结构与列宽对应关系
This commit is contained in:
2026-11-21 19:10:37 +08:00
parent cdbea79ba6
commit 7280ccb5f3
2 changed files with 91 additions and 7 deletions
@@ -242,6 +242,18 @@ onMounted(fetchLogs)
</template>
</VEmpty>
<template v-else>
<!-- 列题头:列宽与下方数据行各 VEntityField 的 width 一一对应 -->
<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-resource">资源 / 路径</span>
</div>
<div class="header-end">
<span class="header-col col-status">结果</span>
<span class="header-col col-ip">IP</span>
</div>
</div>
<VEntity
v-for="log in logs"
:key="log.metadata.name"
@@ -249,19 +261,20 @@ onMounted(fetchLogs)
@click="openDetail(log)"
>
<template #start>
<VEntityField :title="displayUsername(log.spec.username)">
<VEntityField :title="displayUsername(log.spec.username)" width="12rem">
<template #description>
<span class="row-sub">{{ formatTime(log.metadata.creationTimestamp) }}</span>
</template>
</VEntityField>
<VEntityField :title="log.spec.method">
<template #extra>
<!-- 动作列:仅保留彩色徽标(原先 title 与徽标重复渲染两个相同文案) -->
<VEntityField width="6rem">
<template #title>
<span class="method-badge" :class="methodBadgeClass(log.spec.method)">
{{ log.spec.method }}
</span>
</template>
</VEntityField>
<VEntityField>
<VEntityField width="20rem">
<template #title>
<span class="resource-text">
{{ log.spec.resourceType }}
@@ -274,8 +287,10 @@ onMounted(fetchLogs)
</VEntityField>
</template>
<template #end>
<VEntityField>
<template #extra>
<!-- 结果列:徽标经 #title 插槽渲染(当前版本组件在无 title 时
不渲染 #extra,原先徽标实际不可见) -->
<VEntityField width="4rem">
<template #title>
<span
class="status-badge"
:class="isSuccessful(log.spec.statusCode) ? 'status-ok' : 'status-fail'"
@@ -284,7 +299,7 @@ onMounted(fetchLogs)
</span>
</template>
</VEntityField>
<VEntityField :title="log.spec.remoteIp" />
<VEntityField :title="log.spec.remoteIp" width="9rem" />
</template>
</VEntity>
</template>
@@ -366,6 +381,32 @@ onMounted(fetchLogs)
display: flex;
gap: 0.5rem;
}
/* 列题头:左右内边距与 entity 行(1rem)一致,列宽与数据行字段宽度一一对应 */
.audit-header {
display: flex;
align-items: center;
padding: 0.5rem 1rem;
border-bottom: 1px solid #eaecf0;
}
.header-start {
display: flex;
gap: 1rem;
}
.header-end {
display: flex;
gap: 1.5rem;
margin-left: auto;
}
.header-col {
font-size: 0.75rem;
color: #666;
white-space: nowrap;
}
.col-username { width: 12rem; }
.col-method { width: 6rem; }
.col-resource { width: 20rem; }
.col-status { width: 4rem; }
.col-ip { width: 9rem; }
.audit-error {
--tw-ring-color: transparent;
/* 错误提示位于白卡上方,与卡片留出间距 */