From 6da5fa01b9cc492cde822343887d4b5c47c1c598 Mon Sep 17 00:00:00 2001 From: shaw Date: Sat, 14 Mar 2026 20:39:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E4=BF=AE=E5=A4=8D=E8=BF=90?= =?UTF-8?q?=E7=BB=B4=E8=AE=BE=E7=BD=AE=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AE=E5=A7=8B=E7=BB=88=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端默认 alert.enabled=true 但 recipients 为空,前端验证将其视为 错误并阻断保存按钮。移除该阻断性验证,改为保存时自动禁用无收件人 的邮件通知配置。 --- .../ops/components/OpsSettingsDialog.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/src/views/admin/ops/components/OpsSettingsDialog.vue b/frontend/src/views/admin/ops/components/OpsSettingsDialog.vue index 5d87daf6..5dcd5c62 100644 --- a/frontend/src/views/admin/ops/components/OpsSettingsDialog.vue +++ b/frontend/src/views/admin/ops/components/OpsSettingsDialog.vue @@ -131,15 +131,7 @@ const validation = computed(() => { } } - // 验证邮件配置 - if (emailConfig.value) { - if (emailConfig.value.alert.enabled && emailConfig.value.alert.recipients.length === 0) { - errors.push(t('admin.ops.email.validation.alertRecipientsRequired')) - } - if (emailConfig.value.report.enabled && emailConfig.value.report.recipients.length === 0) { - errors.push(t('admin.ops.email.validation.reportRecipientsRequired')) - } - } + // 邮件配置: 启用但无收件人时不阻断保存, 保存时会自动禁用 // 验证高级设置 if (advancedSettings.value) { @@ -181,6 +173,15 @@ async function saveAllSettings() { saving.value = true try { + // 无收件人时自动禁用邮件通知 + if (emailConfig.value) { + if (emailConfig.value.alert.enabled && emailConfig.value.alert.recipients.length === 0) { + emailConfig.value.alert.enabled = false + } + if (emailConfig.value.report.enabled && emailConfig.value.report.recipients.length === 0) { + emailConfig.value.report.enabled = false + } + } await Promise.all([ runtimeSettings.value ? opsAPI.updateAlertRuntimeSettings(runtimeSettings.value) : Promise.resolve(), emailConfig.value ? opsAPI.updateEmailNotificationConfig(emailConfig.value) : Promise.resolve(),