From 962c58fdd1afae989d5534e47a93568eb9f4e55c Mon Sep 17 00:00:00 2001 From: zAhYAng Date: Tue, 11 Aug 2026 21:41:43 +0800 Subject: [PATCH] feat: add WeCom notification settings --- web/src/components/settings/PushTabs.tsx | 52 ++++++++++++++++++- web/src/components/settings/model.ts | 64 +++++++++++++++++------- web/src/pages/SettingsPage.tsx | 25 ++++++++- web/src/types.ts | 1 + 4 files changed, 122 insertions(+), 20 deletions(-) diff --git a/web/src/components/settings/PushTabs.tsx b/web/src/components/settings/PushTabs.tsx index 0f8f07d..0a1dae7 100644 --- a/web/src/components/settings/PushTabs.tsx +++ b/web/src/components/settings/PushTabs.tsx @@ -6,7 +6,7 @@ import { Select } from "../ui/Select"; import { Switch } from "../ui/Switch"; import { ChannelHeader, EmptyLine, Field, UrlListEditor } from "./controls"; import { HEADER_NAME_SUGGESTIONS, nextHeaderRowId } from "./model"; -import type { BarkForm, EmailForm, HeaderRow, WebhookForm } from "./model"; +import type { BarkForm, EmailForm, HeaderRow, WebhookForm, WecomForm } from "./model"; const HEADER_LIST_ID = "vocat-webhook-header-names"; @@ -267,3 +267,53 @@ export function WebhookTab({ value, onChange, testing, onTest }: PushChannelProp ); } + +export function WecomTab({ value, onChange, testing, onTest }: PushChannelProps) { + const { t } = useI18n(); + const off = !value.enabled; + const complete = hasAnyUrl(value.urls) && !!value.payloadTemplate.trim(); + return ( +
+ onChange({ enabled })} + actions={ + + } + /> + +
+
+ {t("每个企业微信消息推送 Webhook URL 单独占一行,点击添加 URL 新增一行;不使用逗号、空格或换行分隔多个 URL。")} +
+ onChange({ urls })} + enabled={value.enabled} + placeholder="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..." + emptyText={t("尚未配置任何企业微信 Webhook URL,点击右侧添加按钮。")} + /> + + {t("支持完整企业微信消息 JSON。变量必须作为 JSON 值使用,例如")} {"{{message}}"}。 + {t("可用变量:{{event}}、{{title}}、{{message}}、{{timestamp}}、{{content}}、{{number}}、{{device_id}}、{{device_name}}、{{device_label}}、{{time}}。")} + + } + > +