From 62c1a8b0d1e8edde0627c3ce2146b6afcba861da Mon Sep 17 00:00:00 2001 From: dengqichen Date: Wed, 12 Nov 2025 14:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-forms/EmailConfigForm.tsx | 34 ---------- .../config-forms/WeworkConfigForm.tsx | 62 ------------------- .../config-strategies/EmailConfigStrategy.ts | 13 +--- .../config-strategies/WeworkConfigStrategy.ts | 18 +----- .../List/components/schemas/formSchema.ts | 3 - .../Deploy/NotificationChannel/List/types.ts | 14 ----- 6 files changed, 4 insertions(+), 140 deletions(-) diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-forms/EmailConfigForm.tsx b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-forms/EmailConfigForm.tsx index 5c3c20a4..1812c2b1 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-forms/EmailConfigForm.tsx +++ b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-forms/EmailConfigForm.tsx @@ -5,34 +5,13 @@ import React from 'react'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Switch } from '@/components/ui/switch'; -import { TagList } from '@/components/ui/tag-list'; import type { ConfigComponentProps } from '../config-strategies/types'; export const EmailConfigForm: React.FC = ({ register, errors, setValue, - configState, - updateConfigState, }) => { - const handleAddReceiver = () => { - if (configState.newReceiver?.trim() && !configState.receivers?.includes(configState.newReceiver.trim())) { - updateConfigState({ - receivers: [...(configState.receivers || []), configState.newReceiver.trim()], - newReceiver: '', - }); - } - }; - - const handleRemoveReceiver = (index: number) => { - updateConfigState({ - receivers: configState.receivers?.filter((_: any, i: number) => i !== index) || [], - }); - }; - - const validateEmail = (email: string): boolean => { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); - }; return ( <> @@ -132,19 +111,6 @@ export const EmailConfigForm: React.FC = ({ - updateConfigState({ newReceiver: value })} - onAddTag={handleAddReceiver} - onRemoveTag={handleRemoveReceiver} - validate={validateEmail} - validationError="请输入有效的邮箱地址格式" - />
= ({ register, errors, - configState, - updateConfigState, }) => { - const handleAddMobile = () => { - if (configState.newMobile?.trim() && !configState.mentionedMobiles?.includes(configState.newMobile.trim())) { - updateConfigState({ - mentionedMobiles: [...(configState.mentionedMobiles || []), configState.newMobile.trim()], - newMobile: '', - }); - } - }; - - const handleRemoveMobile = (index: number) => { - updateConfigState({ - mentionedMobiles: configState.mentionedMobiles?.filter((_: any, i: number) => i !== index) || [], - }); - }; - - const handleAddUser = () => { - if (configState.newUser?.trim() && !configState.mentionedUsers?.includes(configState.newUser.trim())) { - updateConfigState({ - mentionedUsers: [...(configState.mentionedUsers || []), configState.newUser.trim()], - newUser: '', - }); - } - }; - - const handleRemoveUser = (index: number) => { - updateConfigState({ - mentionedUsers: configState.mentionedUsers?.filter((_: any, i: number) => i !== index) || [], - }); - }; - - const validateMobile = (mobile: string): boolean => { - return /^1[3-9]\d{9}$/.test(mobile); - }; - return ( <>
@@ -67,31 +30,6 @@ export const WeworkConfigForm: React.FC = ({

)}
- - updateConfigState({ newMobile: value })} - onAddTag={handleAddMobile} - onRemoveTag={handleRemoveMobile} - validate={validateMobile} - validationError="请输入有效的手机号格式" - /> - - updateConfigState({ newUser: value })} - onAddTag={handleAddUser} - onRemoveTag={handleRemoveUser} - /> ); }; diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/EmailConfigStrategy.ts b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/EmailConfigStrategy.ts index f7eb1063..8da9e06a 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/EmailConfigStrategy.ts +++ b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/EmailConfigStrategy.ts @@ -30,23 +30,14 @@ export class EmailConfigStrategy implements ConfigStrategy { } loadFromData(data: any): ConfigState { - if (data.channelType === NotificationChannelType.EMAIL && isEmailConfig(data.config)) { - return { - receivers: data.config.defaultReceivers || [], - newReceiver: '', - }; - } - return { - receivers: [], - newReceiver: '', - }; + // 邮件配置不再需要额外的状态管理 + return {}; } buildConfig(state: ConfigState, formConfig: any): any { return { ...formConfig, channelType: NotificationChannelType.EMAIL, - defaultReceivers: state.receivers || [], }; } } diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/WeworkConfigStrategy.ts b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/WeworkConfigStrategy.ts index d878b39c..883696b8 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/WeworkConfigStrategy.ts +++ b/frontend/src/pages/Deploy/NotificationChannel/List/components/config-strategies/WeworkConfigStrategy.ts @@ -22,28 +22,14 @@ export class WeworkConfigStrategy implements ConfigStrategy { } loadFromData(data: any): ConfigState { - if (data.channelType === NotificationChannelType.WEWORK && isWeworkConfig(data.config)) { - return { - mentionedMobiles: data.config.mentionedMobileList || [], - mentionedUsers: data.config.mentionedList || [], - newMobile: '', - newUser: '', - }; - } - return { - mentionedMobiles: [], - mentionedUsers: [], - newMobile: '', - newUser: '', - }; + // 企业微信配置不再需要额外的状态管理 + return {}; } buildConfig(state: ConfigState, formConfig: any): any { return { ...formConfig, channelType: NotificationChannelType.WEWORK, - mentionedMobileList: state.mentionedMobiles || [], - mentionedList: state.mentionedUsers || [], }; } } diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/components/schemas/formSchema.ts b/frontend/src/pages/Deploy/NotificationChannel/List/components/schemas/formSchema.ts index 34ccd50f..62c00536 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/components/schemas/formSchema.ts +++ b/frontend/src/pages/Deploy/NotificationChannel/List/components/schemas/formSchema.ts @@ -10,8 +10,6 @@ const weworkConfigSchema = z.object({ key: z.string() .min(1, '请输入Webhook Key') .regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i, '请输入有效的UUID格式Key'), - mentionedMobileList: z.array(z.string()).optional(), - mentionedList: z.array(z.string()).optional(), }); // 邮件配置 Schema @@ -26,7 +24,6 @@ const emailConfigSchema = z.object({ password: z.string().min(1, '请输入密码'), from: z.string().email('请输入有效的邮箱地址'), fromName: z.string().optional(), - defaultReceivers: z.array(z.string().email()).optional(), useSsl: z.boolean().optional(), }); diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/types.ts b/frontend/src/pages/Deploy/NotificationChannel/List/types.ts index dd4982e4..8917a630 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/types.ts +++ b/frontend/src/pages/Deploy/NotificationChannel/List/types.ts @@ -33,17 +33,6 @@ export interface WeworkNotificationConfigDTO extends BaseNotificationConfigDTO { * 完整URL格式: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={key} */ key: string; - - /** - * 默认@的手机号列表(可选) - */ - mentionedMobileList?: string[]; - - /** - * 默认@的用户列表(可选) - * 例如:["@all"] 表示@所有人 - */ - mentionedList?: string[]; } // ============================================ @@ -71,9 +60,6 @@ export interface EmailNotificationConfigDTO extends BaseNotificationConfigDTO { /** 发件人名称(可选) */ fromName?: string; - /** 默认收件人列表(可选) */ - defaultReceivers?: string[]; - /** 是否使用SSL(可选,默认true) */ useSsl?: boolean; }