From 497974f398450dc2d9c72554c477f9d106d129b7 Mon Sep 17 00:00:00 2001 From: mapxn <16299874+mapxn@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:49:53 +0800 Subject: [PATCH] feat(web): per-user SMTP fields on Email notification channel (ONE-22) Add smtp_host / smtp_port / smtp_username / smtp_password / smtp_from to the Email channel form, wire zh/en labels through a new optional labelKey on ChannelFieldDef, and keep smtp_password as a password input so the backend-masked value round-trips unchanged. --- web/src/locales/en.json | 7 ++++- web/src/locales/zh.json | 7 ++++- web/src/pages/channels/ChannelPage.tsx | 38 +++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 959c75c..702d87c 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -369,7 +369,12 @@ "notificationHours": "Notification Hours", "notificationHoursHint": "Notifications are sent at most once per hour. Leave empty to allow every hour.", "notificationHoursClear": "Clear", - "notificationHoursNoLimit": "No restriction" + "notificationHoursNoLimit": "No restriction", + "smtpHost": "SMTP Host", + "smtpPort": "SMTP Port", + "smtpUsername": "SMTP Username", + "smtpPassword": "SMTP Password", + "smtpFrom": "From Address" }, "setup": { "title": "Setup", diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index 4f43858..303a36c 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -369,7 +369,12 @@ "notificationHours": "通知时段", "notificationHoursHint": "每小时仅发送一次通知。不选则每小时都会发送通知。", "notificationHoursClear": "清空", - "notificationHoursNoLimit": "不限制" + "notificationHoursNoLimit": "不限制", + "smtpHost": "SMTP 主机", + "smtpPort": "SMTP 端口", + "smtpUsername": "SMTP 用户名", + "smtpPassword": "SMTP 密码", + "smtpFrom": "发件地址" }, "setup": { "title": "初始化", diff --git a/web/src/pages/channels/ChannelPage.tsx b/web/src/pages/channels/ChannelPage.tsx index 45ef214..b34707b 100644 --- a/web/src/pages/channels/ChannelPage.tsx +++ b/web/src/pages/channels/ChannelPage.tsx @@ -13,6 +13,8 @@ import type { NotificationConfig } from "@/types"; interface ChannelFieldDef { key: string; label: string; + /** i18n key; preferred over `label` when present */ + labelKey?: string; type: "text" | "password" | "textarea" | "select"; options?: string[]; placeholder?: string; @@ -88,9 +90,43 @@ const CHANNELS: ChannelDef[] = [ { key: "to", label: "To Address", + labelKey: "channels.toAddress", type: "text", placeholder: "", }, + { + key: "smtp_host", + label: "SMTP Host", + labelKey: "channels.smtpHost", + type: "text", + placeholder: "smtp.example.com", + }, + { + key: "smtp_port", + label: "SMTP Port", + labelKey: "channels.smtpPort", + type: "text", + placeholder: "465", + }, + { + key: "smtp_username", + label: "SMTP Username", + labelKey: "channels.smtpUsername", + type: "text", + }, + { + key: "smtp_password", + label: "SMTP Password", + labelKey: "channels.smtpPassword", + type: "password", + }, + { + key: "smtp_from", + label: "From Address", + labelKey: "channels.smtpFrom", + type: "text", + placeholder: "noreply@example.com", + }, ], }, { @@ -330,7 +366,7 @@ function ChannelCard({ {channel.fields.map((field) => (