diff --git a/packages/ui/certd-client/src/views/certd/notification/common.tsx b/packages/ui/certd-client/src/views/certd/notification/common.tsx index 95d471963..de81152aa 100644 --- a/packages/ui/certd-client/src/views/certd/notification/common.tsx +++ b/packages/ui/certd-client/src/views/certd/notification/common.tsx @@ -151,7 +151,10 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) { name: "api-test", action: "TestRequest" }, - order: 999 + order: 999, + col: { + span: 24 + } }, column: { show: false diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts index b813fb8ee..b32cf8088 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts @@ -48,10 +48,11 @@ export class WebhookNotification extends BaseNotification { title: 'Headers', component: { name: 'a-textarea', + vModel: 'value', rows: 3, }, helper: '一行一个,格式为key:value', - required: true, + required: false, }) headers = ''; @@ -83,18 +84,31 @@ export class WebhookNotification extends BaseNotification { const data = JSON.parse(bodyStr); const headers: any = {}; - this.headers.split('\n').forEach(item => { - const [key, value] = item.trim().split(':'); - headers[key] = value; - }); - await this.http.request({ - url: this.webhook, - method: this.method, - headers: { - 'Content-Type': `${this.contentType}; charset=UTF-8`, - ...headers, - }, - data: data, - }); + if (this.headers && this.headers.trim()) { + this.headers.split('\n').forEach(item => { + item = item.trim(); + if (item) { + const [key, value] = item.split(':'); + headers[key] = value; + } + }); + } + + try { + await this.http.request({ + url: this.webhook, + method: this.method, + headers: { + 'Content-Type': `${this.contentType}; charset=UTF-8`, + ...headers, + }, + data: data, + }); + } catch (e) { + if (e.response?.data) { + throw new Error(e.message + ',' + JSON.stringify(e.response.data)); + } + throw e; + } } }