From 77419c855286c5223afa3f548ac31a5cc6d0df3d Mon Sep 17 00:00:00 2001 From: xuans Date: Sun, 27 Sep 2026 08:50:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E6=95=9B=E9=82=AE=E4=BB=B6=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E9=A1=B5=E9=9D=A2=E4=B8=BASMTP=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=B4=A6=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dashboard/MailNotificationSettings.css | 16 ++--- .../Dashboard/MailNotificationSettings.vue | 58 ++++++------------- .../src/views/Dashboard/SettingsModal.test.js | 53 +++++++++-------- .../src/views/Dashboard/SettingsPayload.js | 7 +-- 4 files changed, 53 insertions(+), 81 deletions(-) diff --git a/frontend/src/views/Dashboard/MailNotificationSettings.css b/frontend/src/views/Dashboard/MailNotificationSettings.css index 6a49a29..15482f9 100644 --- a/frontend/src/views/Dashboard/MailNotificationSettings.css +++ b/frontend/src/views/Dashboard/MailNotificationSettings.css @@ -1,19 +1,9 @@ -.mail-common-fields, -.mail-channels, .mail-smtp-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; } -.mail-common-fields { - margin-bottom: 14px; -} - -.mail-channels { - grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); -} - .mail-channel { min-width: 0; margin: 0; @@ -42,6 +32,10 @@ margin-top: 12px; } +.mail-recipient-field { + margin-top: 14px; +} + .mail-field > span { display: flex; align-items: center; @@ -83,8 +77,6 @@ } @media (max-width: 700px) { - .mail-common-fields, - .mail-channels, .mail-smtp-fields { grid-template-columns: minmax(0, 1fr); } diff --git a/frontend/src/views/Dashboard/MailNotificationSettings.vue b/frontend/src/views/Dashboard/MailNotificationSettings.vue index 4bc5a4a..e4dce98 100644 --- a/frontend/src/views/Dashboard/MailNotificationSettings.vue +++ b/frontend/src/views/Dashboard/MailNotificationSettings.vue @@ -6,45 +6,14 @@ defineProps({ notification: { type: Object, required: true } }); diff --git a/frontend/src/views/Dashboard/SettingsModal.test.js b/frontend/src/views/Dashboard/SettingsModal.test.js index 54669f1..faa4321 100644 --- a/frontend/src/views/Dashboard/SettingsModal.test.js +++ b/frontend/src/views/Dashboard/SettingsModal.test.js @@ -7,7 +7,7 @@ import { settingsPayload } from "./SettingsPayload.js"; const source = readFileSync(new URL("./SettingsModal.vue", import.meta.url), "utf8"); -test("邮件通知组件保留两种通道且公共字段只出现一次", () => { +test("邮件通知组件只保留 SMTP 通道和收件人配置", () => { const mailSource = readFileSync(new URL("./MailNotificationSettings.vue", import.meta.url), "utf8"); const { descriptor, errors } = parse(mailSource); assert.deepEqual(errors, []); @@ -19,36 +19,41 @@ test("邮件通知组件保留两种通道且公共字段只出现一次", () => compilerOptions: { bindingMetadata: script.bindings }, }); assert.deepEqual(compiled.errors, []); - for (const field of ["http_enabled", "smtp_enabled", "sender_email", "smtp_password"]) { + for (const field of ["smtp_enabled", "smtp_password"]) { assert.equal(mailSource.split(`v-model="notification.${field}"`).length - 1, 1); } + assert.doesNotMatch(mailSource, /HTTP 接口|sender_email|notification\.http_enabled/); assert.equal(mailSource.split(':value="notification.recipients.join').length - 1, 1); assert.match(source, / { - for (const http of [false, true]) { - for (const smtp of [false, true]) { - const notification = { - http_enabled: http, - smtp_enabled: smtp, - endpoint: "https://mail.example.com", - sender_email: "sender@example.com", - recipients: ["recipient@example.com"], - smtp_host: "smtp.example.com", - smtp_port: 587, - smtp_username: "sender", - smtp_password: "", - smtp_mode: "starttls", - smtp_credential_configured: true, - }; - const payload = settingsPayload({ notification }).notification; - const { smtp_credential_configured, ...expected } = notification; - assert.deepEqual(payload, expected); - assert.equal(notification.smtp_credential_configured, true); - } - } +test("邮件设置只提交 SMTP 配置,不提交 HTTP 和自定义发件人", () => { + const notification = { + http_enabled: true, + smtp_enabled: true, + endpoint: "https://mail.example.com", + sender_email: "sender@example.com", + recipients: ["recipient@example.com"], + smtp_host: "smtp.example.com", + smtp_port: 587, + smtp_username: "notify:system@example.com", + smtp_password: "", + smtp_mode: "starttls", + smtp_credential_configured: true, + }; + const payload = settingsPayload({ notification }).notification; + assert.deepEqual(payload, { + smtp_enabled: true, + smtp_host: "smtp.example.com", + smtp_port: 587, + smtp_username: "notify:system@example.com", + smtp_password: "", + smtp_mode: "starttls", + recipients: ["recipient@example.com"], + }); + assert.equal(notification.http_enabled, true); + assert.equal(notification.sender_email, "sender@example.com"); }); test("通知字段校验失败时切换到合并后的邮件通知页", async () => { diff --git a/frontend/src/views/Dashboard/SettingsPayload.js b/frontend/src/views/Dashboard/SettingsPayload.js index 8dc930f..113dcfd 100644 --- a/frontend/src/views/Dashboard/SettingsPayload.js +++ b/frontend/src/views/Dashboard/SettingsPayload.js @@ -10,12 +10,11 @@ const requestFields = { "propagation_polling_interval_secs", ], notification: [ - "http_enabled", "smtp_enabled", "smtp_host", "smtp_port", + "smtp_enabled", "smtp_host", "smtp_port", "smtp_username", "smtp_password", "smtp_mode", "smtp_allow_plaintext_auth", - "http_credentials", "provider", "endpoint", "http_path", "http_login_path", - "http_auth_mode", "event_mode", "include_deployment_details", + "event_mode", "include_deployment_details", "include_certificate_serial", "include_management_url", "sender_name", - "sender_email", "recipients", "timeout_secs", "retry_count", + "recipients", "timeout_secs", "retry_count", "retry_intervals_secs", ], };