diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 5a808ec8..da620f66 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -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', + }, }, } }, diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 3a8bbf75..d0209398 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -3042,6 +3042,13 @@ export default { targetId: "대상 ID", details: "원본 상세", }, + drawer: { + sectionSummary: "이벤트 요약", + sectionIdentifiers: "관련 식별자", + sectionRequest: "요청 정보", + targetChange: "변경 내용", + requestMethod: "요청 메서드", + }, }, }, }, diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 37d36c48..8c23aa58 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -2729,6 +2729,13 @@ export default { targetType: 'Тип цели', targetId: 'ID цели', details: 'Сырые детали' + }, + drawer: { + sectionSummary: 'Сводка события', + sectionIdentifiers: 'Связанные идентификаторы', + sectionRequest: 'Запрос', + targetChange: 'Изменение', + requestMethod: 'Метод' } } } diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 021574a6..ba7b7bfd 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -3054,6 +3054,13 @@ export default { targetId: "目标 ID", details: "原始详情", }, + drawer: { + sectionSummary: "事件概要", + sectionIdentifiers: "关联标识", + sectionRequest: "请求信息", + targetChange: "变更内容", + requestMethod: "请求方法", + }, }, }, }, diff --git a/frontend/src/views/system/SystemAuditLog.vue b/frontend/src/views/system/SystemAuditLog.vue index ad22a34c..61be2eb5 100644 --- a/frontend/src/views/system/SystemAuditLog.vue +++ b/frontend/src/views/system/SystemAuditLog.vue @@ -46,9 +46,7 @@ :columns="auditColumns" size="medium" hover - expand-on-row-click - :expanded-row-keys="auditExpandedRowKeys" - @expand-change="onAuditExpandChange" + @row-click="openAuditDetail" > - @@ -125,6 +97,76 @@

+ + + + @@ -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(null) const auditLoadSentinelEl = ref(null) let auditScrollObserver: IntersectionObserver | null = null +const auditDetailVisible = ref(false) +const selectedAuditEntry = ref(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 { return `${oldStr} → ${newStr}` } -const auditExpandedRowKeys = ref([]) +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; - } } diff --git a/frontend/src/views/system/SystemSettings.vue b/frontend/src/views/system/SystemSettings.vue index 23566663..7b69bfde 100644 --- a/frontend/src/views/system/SystemSettings.vue +++ b/frontend/src/views/system/SystemSettings.vue @@ -49,29 +49,17 @@