From 5d5bdb4f52a8f15c816008dba9f724553f55c906 Mon Sep 17 00:00:00 2001 From: JiangQiming <291854119@qq.com> Date: Tue, 17 Jan 2023 11:47:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=20=E8=A7=A3=E5=86=B3=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=AA=8C=E8=AF=81=E5=A7=8B=E7=BB=88=E4=B8=8D?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/notice/Config/Detail/index.vue | 10 ++- src/views/notice/Config/types.d.ts | 82 ++++++++++++++++-------- src/views/notice/const.ts | 54 ++++++++++------ 3 files changed, 98 insertions(+), 48 deletions(-) diff --git a/src/views/notice/Config/Detail/index.vue b/src/views/notice/Config/Detail/index.vue index 59bd6ccf..700c6d89 100644 --- a/src/views/notice/Config/Detail/index.vue +++ b/src/views/notice/Config/Detail/index.vue @@ -313,7 +313,6 @@ const formData = ref({ configuration: { appKey: '', appSecret: '', - url: '', }, description: '', name: '', @@ -325,13 +324,20 @@ const formData = ref({ watch( () => formData.value.type, (val) => { - formData.value.configuration = CONFIG_FIELD_MAP[val]; + // formData.value.configuration = Object.values(CONFIG_FIELD_MAP[val])[0]; msgType.value = MSG_TYPE[val]; formData.value.provider = msgType.value[0].value; }, ); +computed(() => + Object.assign( + formData.value.configuration, + CONFIG_FIELD_MAP[formData.value.type][formData.value.provider], + ), +); + // 验证规则 const formRules = ref({ type: [{ required: true, message: '请选择通知方式' }], diff --git a/src/views/notice/Config/types.d.ts b/src/views/notice/Config/types.d.ts index a2891814..c9ade1d7 100644 --- a/src/views/notice/Config/types.d.ts +++ b/src/views/notice/Config/types.d.ts @@ -3,34 +3,62 @@ export interface IHeaders { key: string; value: string; } +export interface IConfiguration { + // 钉钉 + appKey?: string; + appSecret?: string; + url?: string; + // 微信 + corpId?: string; + corpSecret?: string; + // 邮件 + host?: string; + port?: number; + ssl?: boolean; + sender?: string; + username?: string; + password?: string; + // 语音 + regionId?: string; + accessKeyId?: string; + secret?: string; + // 短信 + regionId?: string; + accessKeyId?: string; + secret?: string; + // webhook + // url?: string; + headers?: IHeaders[]; +} export type ConfigFormData = { - configuration: { - // 钉钉 - appKey?: string; - appSecret?: string; - url?: string; - // 微信 - corpId?: string; - corpSecret?: string; - // 邮件 - host?: string; - port?: number; - ssl?: boolean; - sender?: string; - username?: string; - password?: string; - // 语音 - regionId?: string; - accessKeyId?: string; - secret?: string; - // 短信 - regionId?: string; - accessKeyId?: string; - secret?: string; - // webhook - // url?: string; - headers?: IHeaders[]; - }; + configuration: IConfiguration; + // configuration: { + // // 钉钉 + // appKey?: string; + // appSecret?: string; + // url?: string; + // // 微信 + // corpId?: string; + // corpSecret?: string; + // // 邮件 + // host?: string; + // port?: number; + // ssl?: boolean; + // sender?: string; + // username?: string; + // password?: string; + // // 语音 + // regionId?: string; + // accessKeyId?: string; + // secret?: string; + // // 短信 + // regionId?: string; + // accessKeyId?: string; + // secret?: string; + // // webhook + // // url?: string; + // headers?: IHeaders[]; + // }; description: string; name: string; provider: string; diff --git a/src/views/notice/const.ts b/src/views/notice/const.ts index a0e48d70..ec814842 100644 --- a/src/views/notice/const.ts +++ b/src/views/notice/const.ts @@ -93,36 +93,52 @@ export const MSG_TYPE = { // 配置 export const CONFIG_FIELD_MAP = { dingTalk: { - appKey: undefined, - appSecret: undefined, - url: undefined, + dingTalkMessage: { + appKey: '', + appSecret: '', + }, + dingTalkRobotWebHook: { + url: '', + } }, weixin: { - corpId: undefined, - corpSecret: undefined, + corpMessage: { + corpId: '', + corpSecret: '', + }, + // officialMessage: {}, }, email: { - host: undefined, - port: 25, - ssl: false, - sender: undefined, - username: undefined, - password: undefined, + embedded: { + host: '', + port: 25, + ssl: false, + sender: '', + username: '', + password: '', + } }, voice: { - regionId: undefined, - accessKeyId: undefined, - secret: undefined, + aliyun: { + regionId: '', + accessKeyId: '', + secret: '', + } }, sms: { - regionId: undefined, - accessKeyId: undefined, - secret: undefined, + aliyunSms: { + regionId: '', + accessKeyId: '', + secret: '', + } }, webhook: { - url: undefined, - headers: [], + http: { + url: undefined, + headers: [], + } }, + }; // 模板