Add WeCom machine name for multi-node push labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-30 17:28:32 +08:00
parent 021b0d0a22
commit 8ceb521049
6 changed files with 62 additions and 5 deletions
+1
View File
@@ -359,6 +359,7 @@ export type NotifySettings = {
webhook_configured: boolean;
webhook_url_masked: string | null;
venue_label: string;
machine_name?: string;
};
export async function downloadBackup(name: string): Promise<void> {
+27 -3
View File
@@ -117,6 +117,7 @@ export default function SettingsPage() {
const [runtimeOk, setRuntimeOk] = useState("");
const [wecomEnabled, setWecomEnabled] = useState(false);
const [wecomWebhook, setWecomWebhook] = useState("");
const [wecomMachineName, setWecomMachineName] = useState("");
const [wecomMeta, setWecomMeta] = useState<NotifySettings | null>(null);
const [wecomOk, setWecomOk] = useState("");
@@ -153,6 +154,7 @@ export default function SettingsPage() {
.then((n) => {
setWecomMeta(n);
setWecomEnabled(n.enabled === true);
setWecomMachineName(n.machine_name || "");
})
.catch(() => undefined);
}
@@ -452,7 +454,10 @@ export default function SettingsPage() {
setErr("");
setWecomOk("");
try {
const body: Record<string, unknown> = { enabled: wecomEnabled };
const body: Record<string, unknown> = {
enabled: wecomEnabled,
machine_name: wecomMachineName.trim(),
};
if (wecomWebhook.trim()) body.webhook_url = wecomWebhook.trim();
const n = await apiFetch<NotifySettings>("/api/settings/notify", {
method: "PUT",
@@ -460,6 +465,7 @@ export default function SettingsPage() {
});
setWecomMeta(n);
setWecomEnabled(n.enabled === true);
setWecomMachineName(n.machine_name || "");
setWecomWebhook("");
setWecomOk(
n.enabled
@@ -483,6 +489,7 @@ export default function SettingsPage() {
);
setWecomMeta(n);
setWecomOk(n.detail || "测试消息已发送,请查看企业微信群");
if (n.machine_name != null) setWecomMachineName(n.machine_name || "");
} catch (ex) {
setErr(ex instanceof Error ? ex.message : String(ex));
}
@@ -1379,6 +1386,18 @@ export default function SettingsPage() {
<section className="settings-section">
<h3></h3>
<div className="settings-fields">
<div className="field">
<label htmlFor="wecomMachine"></label>
<input
id="wecomMachine"
className="mono"
autoComplete="off"
maxLength={64}
placeholder="例如 云A / 云B(推送标题前缀)"
value={wecomMachineName}
onChange={(e) => setWecomMachineName(e.target.value)}
/>
</div>
<div className="field">
<label htmlFor="wecomEn"></label>
<select
@@ -1450,14 +1469,19 @@ export default function SettingsPage() {
</li>
<li>
Webhook MarkdownOPEN/CLOSE/START/PAUSE/FAULT
A·OKX LIVE
<span className="mono">
{wecomMachineName || wecomMeta?.machine_name || "未命名"}
</span>
<span className="mono">
{wecomMeta?.venue_label ||
(runtime?.mode === "LIVE"
? `实盘·${(runtime.exchange || "okx").toUpperCase()}`
: "模拟盘")}
</span>
////·
////
</li>
<li>
Webhook