Add WeCom machine name for multi-node push labels.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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,推送 Markdown,带标识(OPEN/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。留空保存不覆盖已有
|
||||
|
||||
Reference in New Issue
Block a user