feat(notify): add gotify

This commit is contained in:
catfishlty
2025-04-01 10:53:41 +08:00
parent 893391a3d1
commit 00ec2ce33e
11 changed files with 263 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import { useAntdForm } from "@/hooks";
import NotifyChannelEditFormBarkFields from "./NotifyChannelEditFormBarkFields";
import NotifyChannelEditFormDingTalkFields from "./NotifyChannelEditFormDingTalkFields";
import NotifyChannelEditFormEmailFields from "./NotifyChannelEditFormEmailFields";
import NotifyChannelEditFormGotifyFields from "./NotifyChannelEditFormGotifyFields.tsx";
import NotifyChannelEditFormLarkFields from "./NotifyChannelEditFormLarkFields";
import NotifyChannelEditFormServerChanFields from "./NotifyChannelEditFormServerChanFields";
import NotifyChannelEditFormTelegramFields from "./NotifyChannelEditFormTelegramFields";
@@ -48,6 +49,8 @@ const NotifyChannelEditForm = forwardRef<NotifyChannelEditFormInstance, NotifyCh
return <NotifyChannelEditFormDingTalkFields />;
case NOTIFY_CHANNELS.EMAIL:
return <NotifyChannelEditFormEmailFields />;
case NOTIFY_CHANNELS.GOTIFY:
return <NotifyChannelEditFormGotifyFields />;
case NOTIFY_CHANNELS.LARK:
return <NotifyChannelEditFormLarkFields />;
case NOTIFY_CHANNELS.SERVERCHAN:

View File

@@ -0,0 +1,46 @@
import { useTranslation } from "react-i18next";
import { Form, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
const NotifyChannelEditFormGotifyFields = () => {
const { t } = useTranslation();
const formSchema = z.object({
url: z.string({ message: t("settings.notification.channel.form.gotify_url.placeholder") }).url({ message: t("common.errmsg.url_invalid") }),
token: z.string({ message: t("settings.notification.channel.form.gotify_token.placeholder") }),
priority: z.preprocess(val => Number(val), z.number({ message: t("settings.notification.channel.form.gotify_priority.placeholder") }).gte(0, { message: t("settings.notification.channel.form.gotify_priority.error.gte0") })),
});
const formRule = createSchemaFieldRule(formSchema);
return (
<>
<Form.Item
name="url"
label={t("settings.notification.channel.form.gotify_url.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_url.tooltip") }}></span>}
>
<Input placeholder={t("settings.notification.channel.form.gotify_url.placeholder")} />
</Form.Item>
<Form.Item
name="token"
label={t("settings.notification.channel.form.gotify_token.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_token.tooltip") }}></span>}
>
<Input placeholder={t("settings.notification.channel.form.gotify_token.placeholder")} />
</Form.Item>
<Form.Item
name="priority"
label={t("settings.notification.channel.form.gotify_priority.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_priority.tooltip") }}></span>}
>
<Input placeholder={t("settings.notification.channel.form.gotify_priority.placeholder")} />
</Form.Item>
</>
);
};
export default NotifyChannelEditFormGotifyFields;