Files
AllinSSL/frontend/apps/allin-ssl/src/views/settings/components/channel/WebhookChannelModel.tsx
chudong 8eed78f1c2 【调整】SSH地址支持域名形式
【新增】支持自定义监控端口
【新增】通知类型-企业微信
【新增】申请证书(Buypass)、自定义ACME服务器地址
【新增】授权API管理(namesilo、Bunny、Gcore、name.com、京东云)
2025-06-07 17:37:42 +08:00

85 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useForm, useModalHooks } from '@baota/naive-ui/hooks'
import { useError } from '@baota/hooks/error'
import { useWebhookChannelFormController } from './useController'
import { useStore } from '@settings/useStore'
import type { ReportWebhook, ReportType } from '@/types/setting'
/**
* Webhook通知渠道表单组件
*/
export default defineComponent({
name: 'WebhookChannelModel',
props: {
data: {
type: Object as PropType<ReportType<ReportWebhook> | null>,
default: () => null,
},
},
setup(props: { data: ReportType<ReportWebhook> | null }) {
const { handleError } = useError()
const { confirm } = useModalHooks()
const { fetchNotifyChannels } = useStore()
const { config, rules, webhookChannelForm, submitForm } = useWebhookChannelFormController()
if (props.data) {
const { name, config } = props.data
webhookChannelForm.value = {
name,
...config,
}
}
// 使用表单hooks
const {
component: WebhookForm,
example,
data,
} = useForm({
config,
defaultValue: webhookChannelForm,
rules,
})
// 关联确认按钮
confirm(async (close) => {
try {
const { name, ...other } = data.value
await example.value?.validate()
const res = await submitForm(
{
type: 'webhook',
name: name || '',
config: other,
},
example,
props.data?.id,
)
fetchNotifyChannels()
if (res) close()
} catch (error) {
handleError(error)
}
})
return () => (
<div class="webhook-channel-form">
<WebhookForm labelPlacement="top"></WebhookForm>
{/* 模板变量说明 */}
<div class="mt-4 p-4 bg-gray-50 rounded-md">
<div class="font-medium text-gray-700 mb-3 text-xl"></div>
<div class="text-gray-600 space-y-3 text-lg">
<div>
<code class="px-2 py-1 bg-gray-200 rounded text-lg font-mono">__subject__</code>
</div>
<div>
<code class="px-2 py-1 bg-gray-200 rounded text-lg font-mono">__body__</code>
</div>
</div>
</div>
</div>
)
},
})