feat(i18n): add drawer localization for audit log details

Enhance internationalization support by adding new localization entries for the audit log detail drawer in English, Korean, Russian, and Chinese. This includes sections for event summary, related IDs, request information, and method.
This commit is contained in:
wizardchen
2026-07-21 15:39:07 +08:00
committed by lyingbug
parent 23db592c4a
commit 171fbd0dca
6 changed files with 301 additions and 168 deletions
+7
View File
@@ -4045,6 +4045,13 @@ export default {
targetId: 'Target ID',
details: 'Raw details',
},
drawer: {
sectionSummary: 'Event summary',
sectionIdentifiers: 'Related IDs',
sectionRequest: 'Request',
targetChange: 'Change',
requestMethod: 'Method',
},
},
}
},
+7
View File
@@ -3042,6 +3042,13 @@ export default {
targetId: "대상 ID",
details: "원본 상세",
},
drawer: {
sectionSummary: "이벤트 요약",
sectionIdentifiers: "관련 식별자",
sectionRequest: "요청 정보",
targetChange: "변경 내용",
requestMethod: "요청 메서드",
},
},
},
},
+7
View File
@@ -2729,6 +2729,13 @@ export default {
targetType: 'Тип цели',
targetId: 'ID цели',
details: 'Сырые детали'
},
drawer: {
sectionSummary: 'Сводка события',
sectionIdentifiers: 'Связанные идентификаторы',
sectionRequest: 'Запрос',
targetChange: 'Изменение',
requestMethod: 'Метод'
}
}
}
+7
View File
@@ -3054,6 +3054,13 @@ export default {
targetId: "目标 ID",
details: "原始详情",
},
drawer: {
sectionSummary: "事件概要",
sectionIdentifiers: "关联标识",
sectionRequest: "请求信息",
targetChange: "变更内容",
requestMethod: "请求方法",
},
},
},
},
+240 -86
View File
@@ -46,9 +46,7 @@
:columns="auditColumns"
size="medium"
hover
expand-on-row-click
:expanded-row-keys="auditExpandedRowKeys"
@expand-change="onAuditExpandChange"
@row-click="openAuditDetail"
>
<template #created_at="{ row }">
<div class="audit-time">
@@ -84,32 +82,6 @@
{{ t('system.globalSettings.audit.outcome.' + row.outcome) }}
</t-tag>
</template>
<template #expandedRow="{ row }">
<div class="audit-expanded">
<div class="audit-expanded-grid">
<div class="audit-expanded-cell">
<span class="audit-expanded-label">{{ t('system.globalSettings.audit.expanded.actorId') }}</span>
<span class="audit-expanded-value mono">{{ row.actor_user_id || '—' }}</span>
</div>
<div v-if="row.target_user_id" class="audit-expanded-cell">
<span class="audit-expanded-label">{{ t('system.globalSettings.audit.expanded.targetUserId') }}</span>
<span class="audit-expanded-value mono">{{ row.target_user_id }}</span>
</div>
<div v-if="row.target_type" class="audit-expanded-cell">
<span class="audit-expanded-label">{{ t('system.globalSettings.audit.expanded.targetType') }}</span>
<span class="audit-expanded-value mono">{{ row.target_type }}</span>
</div>
<div v-if="row.target_id" class="audit-expanded-cell">
<span class="audit-expanded-label">{{ t('system.globalSettings.audit.expanded.targetId') }}</span>
<span class="audit-expanded-value mono">{{ row.target_id }}</span>
</div>
</div>
<div class="audit-expanded-details">
<span class="audit-expanded-label">{{ t('system.globalSettings.audit.expanded.details') }}</span>
<pre class="audit-expanded-json mono">{{ auditDetailsJSON(row) }}</pre>
</div>
</div>
</template>
</t-table>
</div>
@@ -125,6 +97,76 @@
</p>
</div>
</div>
<SettingDrawer
v-model:visible="auditDetailVisible"
class="audit-detail-drawer"
:title="auditDetailTitle"
:description="auditDetailDescription"
icon="file-paste"
width="640px"
:min-width="480"
:max-width="960"
storage-key="setting-drawer:width:system-audit-detail"
hide-footer
>
<template v-if="selectedAuditEntry">
<section class="setting-drawer__section">
<h4 class="setting-drawer__section-title">
{{ t('system.globalSettings.audit.drawer.sectionSummary') }}
</h4>
<dl class="audit-detail-fields">
<div
v-for="field in auditSummaryFields(selectedAuditEntry)"
:key="field.key"
class="audit-detail-field"
>
<dt>{{ field.label }}</dt>
<dd :title="field.value">{{ field.value }}</dd>
</div>
</dl>
</section>
<section v-if="auditIdentifierFields(selectedAuditEntry).length > 0" class="setting-drawer__section">
<h4 class="setting-drawer__section-title">
{{ t('system.globalSettings.audit.drawer.sectionIdentifiers') }}
</h4>
<dl class="audit-detail-fields">
<div
v-for="field in auditIdentifierFields(selectedAuditEntry)"
:key="field.key"
class="audit-detail-field"
>
<dt>{{ field.label }}</dt>
<dd class="mono" :title="field.value">{{ field.value }}</dd>
</div>
</dl>
</section>
<section v-if="auditRequestFields(selectedAuditEntry).length > 0" class="setting-drawer__section">
<h4 class="setting-drawer__section-title">
{{ t('system.globalSettings.audit.drawer.sectionRequest') }}
</h4>
<dl class="audit-detail-fields">
<div
v-for="field in auditRequestFields(selectedAuditEntry)"
:key="field.key"
class="audit-detail-field"
>
<dt>{{ field.label }}</dt>
<dd class="mono" :title="field.value">{{ field.value }}</dd>
</div>
</dl>
</section>
<section class="setting-drawer__section">
<h4 class="setting-drawer__section-title">
{{ t('system.globalSettings.audit.expanded.details') }}
</h4>
<pre class="audit-detail-json mono">{{ auditDetailsJSON(selectedAuditEntry) }}</pre>
</section>
</template>
</SettingDrawer>
</div>
</template>
@@ -137,8 +179,15 @@ import {
type AuditLog,
type AuditOutcome,
} from '@/api/system'
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
import { useAuthStore } from '@/stores/auth'
interface AuditDetailField {
key: string
label: string
value: string
}
const authStore = useAuthStore()
const { t, tm, te, locale } = useI18n()
@@ -153,6 +202,9 @@ const auditScrollRoot = ref<HTMLElement | null>(null)
const auditLoadSentinelEl = ref<HTMLElement | null>(null)
let auditScrollObserver: IntersectionObserver | null = null
const auditDetailVisible = ref(false)
const selectedAuditEntry = ref<AuditLog | null>(null)
const auditColumns = computed(() => [
{ colKey: 'created_at', title: t('system.globalSettings.audit.columns.time'), width: 120 },
{ colKey: 'actor', title: t('system.globalSettings.audit.columns.actor'), width: 180 },
@@ -343,12 +395,129 @@ function formatSettingDiff(details: Record<string, unknown>): string {
return `${oldStr} → ${newStr}`
}
const auditExpandedRowKeys = ref<number[]>([])
function formatAuditDateTime(s: string | undefined): string {
if (!s) return '—'
const date = formatAuditDatePart(s)
const time = formatAuditTimePart(s)
return time ? `${date} ${time}` : date
}
function onAuditExpandChange(value: (string | number)[]) {
auditExpandedRowKeys.value = value
.map((v) => (typeof v === 'number' ? v : Number(v)))
.filter((v) => Number.isFinite(v))
function auditActorDisplay(row: AuditLog): string {
if (!row.actor_user_id) {
return t('system.globalSettings.audit.systemActor')
}
const name = auditActorLabel(row.actor_user_id)
return row.actor_role ? `${name} (${auditActorRoleLabel(row.actor_role)})` : name
}
function auditSummaryFields(row: AuditLog): AuditDetailField[] {
const fields: AuditDetailField[] = [
{
key: 'time',
label: t('system.globalSettings.audit.columns.time'),
value: formatAuditDateTime(row.created_at),
},
{
key: 'actor',
label: t('system.globalSettings.audit.columns.actor'),
value: auditActorDisplay(row),
},
{
key: 'action',
label: t('system.globalSettings.audit.columns.action'),
value: formatAuditAction(row.action),
},
{
key: 'outcome',
label: t('system.globalSettings.audit.columns.outcome'),
value: t('system.globalSettings.audit.outcome.' + row.outcome),
},
]
const targetKey = auditTargetKey(row)
if (targetKey) {
fields.push({
key: 'target',
label: t('system.globalSettings.audit.columns.target'),
value: targetKey,
})
}
const diff = auditTargetDiff(row)
if (diff) {
fields.push({
key: 'targetDiff',
label: t('system.globalSettings.audit.drawer.targetChange'),
value: diff,
})
}
return fields
}
function auditIdentifierFields(row: AuditLog): AuditDetailField[] {
const fields: AuditDetailField[] = []
if (row.actor_user_id) {
fields.push({
key: 'actorId',
label: t('system.globalSettings.audit.expanded.actorId'),
value: row.actor_user_id,
})
}
if (row.target_user_id) {
fields.push({
key: 'targetUserId',
label: t('system.globalSettings.audit.expanded.targetUserId'),
value: row.target_user_id,
})
}
if (row.target_type) {
fields.push({
key: 'targetType',
label: t('system.globalSettings.audit.expanded.targetType'),
value: row.target_type,
})
}
if (row.target_id) {
fields.push({
key: 'targetId',
label: t('system.globalSettings.audit.expanded.targetId'),
value: row.target_id,
})
}
return fields
}
function auditRequestFields(row: AuditLog): AuditDetailField[] {
const fields: AuditDetailField[] = []
if (row.request_method) {
fields.push({
key: 'method',
label: t('system.globalSettings.audit.drawer.requestMethod'),
value: row.request_method,
})
}
if (row.request_path) {
fields.push({
key: 'path',
label: t('system.globalSettings.audit.columns.path'),
value: row.request_path,
})
}
return fields
}
const auditDetailTitle = computed(() =>
selectedAuditEntry.value ? formatAuditAction(selectedAuditEntry.value.action) : '',
)
const auditDetailDescription = computed(() =>
selectedAuditEntry.value ? formatAuditDateTime(selectedAuditEntry.value.created_at) : '',
)
function openAuditDetail(context: { row: AuditLog }) {
selectedAuditEntry.value = context.row
auditDetailVisible.value = true
}
function auditDetailsJSON(row: AuditLog): string {
@@ -651,59 +820,49 @@ onUnmounted(() => {
}
}
.audit-expanded {
.audit-detail-fields {
display: flex;
flex-direction: column;
gap: 12px;
padding: 12px 16px;
background: var(--td-bg-color-container-hover);
}
.audit-expanded-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 10px 18px;
}
.audit-expanded-cell {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.audit-expanded-label {
font-size: 11px;
font-weight: 600;
color: var(--td-text-color-secondary);
text-transform: uppercase;
letter-spacing: 0.04em;
}
.audit-expanded-value {
font-size: 12px;
color: var(--td-text-color-primary);
word-break: break-all;
}
.audit-expanded-details {
display: flex;
flex-direction: column;
gap: 4px;
}
.audit-expanded-json {
gap: 10px;
margin: 0;
padding: 10px 12px;
}
.audit-detail-field {
display: grid;
grid-template-columns: 88px minmax(0, 1fr);
gap: 12px;
align-items: baseline;
margin: 0;
dt {
margin: 0;
color: var(--td-text-color-placeholder);
font-size: 12px;
line-height: 1.45;
white-space: nowrap;
}
dd {
margin: 0;
color: var(--td-text-color-primary);
font-size: 13px;
line-height: 1.55;
word-break: break-all;
}
}
.audit-detail-json {
margin: 0;
padding: 12px 14px;
font-size: 12px;
line-height: 1.55;
color: var(--td-text-color-primary);
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
border-radius: 6px;
border-radius: 8px;
white-space: pre-wrap;
word-break: break-all;
max-height: 280px;
max-height: min(420px, 50vh);
overflow: auto;
}
@@ -739,17 +898,12 @@ onUnmounted(() => {
box-shadow: inset 0 -1px 0 var(--td-component-stroke);
}
&:deep(.t-table tbody tr) {
cursor: pointer;
}
&:deep(.t-table tbody tr:hover > td) {
background-color: var(--td-bg-color-container-hover);
}
&:deep(.t-table tbody tr.t-table__expanded-row > td) {
padding: 0 !important;
background-color: transparent;
}
&:deep(.t-table__expandable-icon-cell) {
width: 36px;
}
}
</style>
+33 -82
View File
@@ -49,29 +49,17 @@
</div>
<template v-else>
<div class="auto-save-note">
<t-icon name="check-circle" />
<span>{{ t('system.globalSettings.autoSaveHint') }}</span>
</div>
<!-- Resolver details matter, but are secondary to finding the setting
itself. Keep them one click away instead of occupying the first
viewport on every visit. Native details/summary also gives us a
keyboard-accessible disclosure without extra state. -->
<details class="config-source-details">
<summary>
<span class="config-source-summary">
<t-icon name="info-circle" />
{{ t('system.globalSettings.priorityHint.disclosure') }}
</span>
<t-icon name="chevron-down" class="config-source-chevron" />
</summary>
<div class="settings-intro-panel">
<div class="priority-hint-title">
<t-icon name="info-circle" />
<span>{{ t('system.globalSettings.priorityHint.disclosure') }}</span>
</div>
<ul class="priority-hint-list">
<li>{{ t('system.globalSettings.priorityHint.tier1') }}</li>
<li>{{ t('system.globalSettings.priorityHint.tier2') }}</li>
<li>{{ t('system.globalSettings.priorityHint.tier3') }}</li>
</ul>
</details>
</div>
<t-tabs v-model="activeSettingsSection" class="settings-section-tabs">
<t-tab-panel value="access" :label="sectionTabLabel('access')" />
@@ -86,7 +74,10 @@
</t-tabs>
<section class="settings-section-panel" :aria-labelledby="`settings-section-${activeSettingsSection}`">
<div class="settings-section-intro">
<div
class="settings-section-intro"
:class="{ 'settings-section-intro--runtime': activeSettingsSection === 'runtime' }"
>
<div>
<h3 :id="`settings-section-${activeSettingsSection}`">{{ activeSectionTitle }}</h3>
<p>{{ activeSectionDescription }}</p>
@@ -1322,70 +1313,39 @@ onUnmounted(() => {
}
.auto-save-note {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 10px;
font-size: 13px;
color: var(--td-text-color-secondary);
.t-icon {
color: var(--td-success-color);
}
}
.config-source-details {
.settings-intro-panel {
margin-bottom: 18px;
padding: 12px 14px;
border: 1px solid var(--td-component-stroke);
border-radius: 6px;
background: var(--td-bg-color-container);
summary {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 38px;
padding: 0 12px;
cursor: pointer;
color: var(--td-text-color-secondary);
font-size: 13px;
list-style: none;
&::-webkit-details-marker {
display: none;
}
&:focus-visible {
outline: 2px solid var(--td-brand-color-focus);
outline-offset: 2px;
}
}
&[open] {
background: var(--td-bg-color-secondarycontainer);
.config-source-chevron {
transform: rotate(180deg);
}
}
background: var(--td-bg-color-secondarycontainer);
}
.config-source-summary {
display: inline-flex;
.priority-hint-title {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 8px;
font-size: 13px;
font-weight: 500;
color: var(--td-text-color-secondary);
.t-icon {
color: var(--td-brand-color);
}
}
.config-source-chevron {
flex-shrink: 0;
transition: transform 0.2s ease;
.priority-hint-list {
margin: 0;
padding: 0 0 0 20px;
font-size: 13px;
line-height: 1.65;
color: var(--td-text-color-primary);
list-style: disc;
li + li {
margin-top: 4px;
}
}
.settings-section-tabs {
@@ -1428,6 +1388,10 @@ onUnmounted(() => {
}
}
.settings-section-intro--runtime {
border-bottom: none;
}
.runtime-table-header {
display: grid;
grid-template-columns: minmax(0, 1fr) 280px;
@@ -1481,19 +1445,6 @@ onUnmounted(() => {
}
}
.priority-hint-list {
margin: 0;
padding: 0 36px 12px 34px;
font-size: 13px;
line-height: 1.65;
color: var(--td-text-color-primary);
list-style: disc;
li + li {
margin-top: 4px;
}
}
.sr-only {
position: absolute;
width: 1px;