mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-03 06:52:13 +08:00
fix(frontend): 修复运维设置对话框保存按钮始终禁用的问题
后端默认 alert.enabled=true 但 recipients 为空,前端验证将其视为 错误并阻断保存按钮。移除该阻断性验证,改为保存时自动禁用无收件人 的邮件通知配置。
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user