feat: specialized UI labels for Telegram notification type

This commit is contained in:
Bot
2026-04-16 21:43:50 +08:00
parent d9ec7c362c
commit 48ccde053b
+34 -22
View File
@@ -164,6 +164,7 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
<SelectContent> <SelectContent>
<SelectItem value="1">Webhook</SelectItem> <SelectItem value="1">Webhook</SelectItem>
<SelectItem value="2">SMTP (Email)</SelectItem> <SelectItem value="2">SMTP (Email)</SelectItem>
<SelectItem value="3">Telegram</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
<FormMessage /> <FormMessage />
@@ -175,15 +176,18 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
name="url" name="url"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>{form.watch("type") == 2 ? "SMTP Server (host:port)" : "URL"}</FormLabel> <FormLabel>
{form.watch("type") == 2 ? "SMTP Server (host:port)" :
form.watch("type") == 3 ? "Bot Token" : "URL"}
</FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} placeholder={form.watch("type") == 3 ? "123456:ABC-DEF" : ""} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
{form.watch("type") != 2 && ( {form.watch("type") != 2 && form.watch("type") != 3 && (
<> <>
<FormField <FormField
control={form.control} control={form.control}
@@ -248,28 +252,17 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
name="request_header" name="request_header"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>{form.watch("type") == 2 ? "SMTP User:Pass" : t("RequestHeader")}</FormLabel> <FormLabel>
{form.watch("type") == 2 ? "SMTP User:Pass" :
form.watch("type") == 3 ? "Chat ID" : t("RequestHeader")}
</FormLabel>
<FormControl> <FormControl>
<Textarea <Textarea
className="resize-y" className="resize-y"
placeholder={form.watch("type") == 2 ? "user:pass" : '{"User-Agent":"Nezha-Agent"}'} placeholder={
{...field} form.watch("type") == 2 ? "user:pass" :
/> form.watch("type") == 3 ? "123456789" : '{"User-Agent":"Nezha-Agent"}'
</FormControl> }
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="request_body"
render={({ field }) => (
<FormItem>
<FormLabel>{form.watch("type") == 2 ? "Recipient Email" : t("RequestBody")}</FormLabel>
<FormControl>
<Textarea
className={form.watch("type") == 2 ? "resize-y" : "resize-y h-[240px]"}
placeholder={form.watch("type") == 2 ? "target@example.com" : '...'}
{...field} {...field}
/> />
</FormControl> </FormControl>
@@ -277,6 +270,25 @@ export const NotifierCard: React.FC<NotifierCardProps> = ({ data, mutate }) => {
</FormItem> </FormItem>
)} )}
/> />
{form.watch("type") != 3 && (
<FormField
control={form.control}
name="request_body"
render={({ field }) => (
<FormItem>
<FormLabel>{form.watch("type") == 2 ? "Recipient Email" : t("RequestBody")}</FormLabel>
<FormControl>
<Textarea
className={form.watch("type") == 2 ? "resize-y" : "resize-y h-[240px]"}
placeholder={form.watch("type") == 2 ? "target@example.com" : '...'}
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
)}
<FormField <FormField
control={form.control} control={form.control}
name="verify_tls" name="verify_tls"