From 61a80114eb8ea4330689b2aa958d9e280b3b6449 Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Tue, 21 Jul 2026 20:28:01 +0800 Subject: [PATCH] fix(ops): surface backend reason when system log cleanup is rejected --- frontend/src/i18n/locales/en/admin/ops.ts | 1 + frontend/src/i18n/locales/zh/admin/ops.ts | 1 + .../src/views/admin/ops/components/OpsSystemLogTable.vue | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/i18n/locales/en/admin/ops.ts b/frontend/src/i18n/locales/en/admin/ops.ts index b6df3a911..8210b789a 100644 --- a/frontend/src/i18n/locales/en/admin/ops.ts +++ b/frontend/src/i18n/locales/en/admin/ops.ts @@ -72,6 +72,7 @@ export default { runtimeConfigResetFailed: 'Failed to reset log configuration', cleanupConfirm: 'Clean up system logs matching the current filters? This cannot be undone.', cleanupSuccess: 'Cleanup complete. Deleted {count} log entries.', + cleanupFilterRequired: 'Cleanup requires at least one filter condition (start/end time or another field)', cleanupFailed: 'Failed to clean up system logs' }, requestsTotal: 'Requests (total)', diff --git a/frontend/src/i18n/locales/zh/admin/ops.ts b/frontend/src/i18n/locales/zh/admin/ops.ts index d79dd6ab4..3c8e9b044 100644 --- a/frontend/src/i18n/locales/zh/admin/ops.ts +++ b/frontend/src/i18n/locales/zh/admin/ops.ts @@ -72,6 +72,7 @@ export default { runtimeConfigResetFailed: '重置日志配置失败', cleanupConfirm: '确定要清理匹配当前筛选条件的系统日志吗?此操作不可撤销。', cleanupSuccess: '清理完成,已删除 {count} 条日志。', + cleanupFilterRequired: '清理需要至少一个筛选条件(起止时间或其他字段)', cleanupFailed: '清理系统日志失败' }, requestsTotal: '请求(总计)', diff --git a/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue b/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue index a745adfdc..64b9e0dde 100644 --- a/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue +++ b/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue @@ -6,6 +6,7 @@ import { opsAPI, type OpsRuntimeLogConfig, type OpsSystemLog, type OpsSystemLogS import Pagination from '@/components/common/Pagination.vue' import Select from '@/components/common/Select.vue' import { useAppStore } from '@/stores' +import { extractApiErrorMessage } from '@/utils/apiError' const appStore = useAppStore() const { t } = useI18n() @@ -312,7 +313,11 @@ const cleanupCurrentFilter = async () => { await Promise.all([fetchLogs(), fetchHealth()]) } catch (err: any) { console.error('[OpsSystemLogTable] Failed to cleanup logs', err) - appStore.showError(err?.response?.data?.detail || t('admin.ops.systemLogs.cleanupFailed')) + appStore.showError( + extractApiErrorMessage(err, t('admin.ops.systemLogs.cleanupFailed'), { + OPS_SYSTEM_LOG_CLEANUP_FILTER_REQUIRED: t('admin.ops.systemLogs.cleanupFilterRequired') + }) + ) } }