修复自定义通知

This commit is contained in:
whyour
2022-09-20 17:34:36 +08:00
parent 5168b044a3
commit 1ebcfd8001
5 changed files with 125 additions and 27 deletions
+24 -5
View File
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Typography, Input, Form, Button, Select, message } from 'antd';
import { request } from '@/utils/http';
import config from '@/utils/config';
import { parseBody, parseHeaders } from '@/utils';
const { Option } = Select;
@@ -12,9 +13,15 @@ const NotificationSetting = ({ data }: any) => {
const [form] = Form.useForm();
const handleOk = (values: any) => {
if (values.type == 'closed') {
const { type, webhookBody, webhookContentType } = values;
if (type == 'closed') {
values.type = '';
}
if (type === 'webhook') {
values.webhookHeaders = { ...parseHeaders(values.webhookHeaders) };
values.webhookBody = parseBody(webhookBody, webhookContentType);
}
request
.put(`${config.apiPrefix}user/notification`, {
data: {
@@ -73,10 +80,22 @@ const NotificationSetting = ({ data }: any) => {
rules={[{ required: x.required }]}
style={{ maxWidth: 400 }}
>
<Input.TextArea
autoSize={true}
placeholder={x.placeholder || `输入${x.label}`}
/>
{
x.items ? (
<Select placeholder={x.placeholder || `选择${x.label}`}>
{x.items.map((y) => (
<Option key={y.value} value={y.value}>
{y.label || y.value}
</Option>
))}
</Select>
) : (
<Input.TextArea
autoSize={true}
placeholder={x.placeholder || `请输入${x.label}`}
/>
)
}
</Form.Item>
))}
<Button type="primary" htmlType="submit">