diff --git a/web/strategy-switch-console/index.html b/web/strategy-switch-console/index.html index de95b82..78bf401 100644 --- a/web/strategy-switch-console/index.html +++ b/web/strategy-switch-console/index.html @@ -1260,6 +1260,22 @@

切换摘要

const el = (id) => document.getElementById(id); const t = (key) => copy[state.lang][key] || copy.en[key] || key; + let toastTimer = null; + + function showToast(message, { duration = 4000 } = {}) { + const node = el("toast"); + if (toastTimer) { + window.clearTimeout(toastTimer); + toastTimer = null; + } + node.textContent = message || ""; + if (message && duration > 0) { + toastTimer = window.setTimeout(() => { + node.textContent = ""; + toastTimer = null; + }, duration); + } + } function optionsFor(platform) { return state.accountOptions[platform] && state.accountOptions[platform].length @@ -2663,7 +2679,7 @@

切换摘要

async function dispatchSwitch() { if (!state.auth.allowed) return; - el("toast").textContent = t("dispatching"); + showToast(t("dispatching"), { duration: 0 }); try { const response = await fetch("/api/switch", { method: "POST", @@ -2672,10 +2688,10 @@

切换摘要

}); const payload = await response.json(); if (!response.ok || !payload.ok) throw new Error(payload.error || t("dispatchFailed")); - el("toast").textContent = t("dispatched"); + showToast(t("dispatched"), { duration: 4000 }); if (payload.actions_url) window.open(payload.actions_url, "_blank", "noopener,noreferrer"); } catch (error) { - el("toast").textContent = `${t("dispatchFailed")}: ${error.message}`; + showToast(`${t("dispatchFailed")}: ${error.message}`, { duration: 12000 }); } } @@ -2798,9 +2814,9 @@

切换摘要

el("copy-button").addEventListener("click", async () => { try { await navigator.clipboard.writeText(summaryText()); - el("toast").textContent = t("copied"); + showToast(t("copied"), { duration: 3000 }); } catch { - el("toast").textContent = summaryText(); + showToast(summaryText(), { duration: 0 }); } }); diff --git a/web/strategy-switch-console/page_asset.js b/web/strategy-switch-console/page_asset.js index 5dc35d7..a3924e6 100644 --- a/web/strategy-switch-console/page_asset.js +++ b/web/strategy-switch-console/page_asset.js @@ -1,2 +1,2 @@ // Generated by scripts/sync_strategy_switch_page_asset.py; do not edit by hand. -export const PAGE_HTML = "\n\n\n \n \n \n QuantRuntimeSettings Strategy Switch\n \n\n\n
\n
\n

策略切换

\n

选平台、目标账号和策略,一次执行完成切换。

\n
\n
\n \n \n \n \n
\n
\n\n
\n
\n 初始化控制台\n

读取策略配置

\n

正在读取登录状态、账号配置和当前状态。

\n
\n
\n
\n\n
\n \n\n
\n
\n
\n 当前平台\n

LongBridge

\n
\n\n \n\n
\n \n\n \n\n
\n 模式\n
\n \n \n
\n
\n\n
\n \n\n \n
\n\n
\n \n\n \n\n \n
\n\n
\n \n\n \n
\n\n
\n \n\n \n\n \n
\n
\n\n
\n \n

登录后才可执行切换。

\n

\n
\n
\n\n \n
\n
\n\n \n\n\n"; +export const PAGE_HTML = "\n\n\n \n \n \n QuantRuntimeSettings Strategy Switch\n \n\n\n
\n
\n

策略切换

\n

选平台、目标账号和策略,一次执行完成切换。

\n
\n
\n \n \n \n \n
\n
\n\n
\n
\n 初始化控制台\n

读取策略配置

\n

正在读取登录状态、账号配置和当前状态。

\n
\n
\n
\n\n
\n \n\n
\n
\n
\n 当前平台\n

LongBridge

\n
\n\n \n\n
\n \n\n \n\n
\n 模式\n
\n \n \n
\n
\n\n
\n \n\n \n
\n\n
\n \n\n \n\n \n
\n\n
\n \n\n \n
\n\n
\n \n\n \n\n \n
\n
\n\n
\n \n

登录后才可执行切换。

\n

\n
\n
\n\n \n
\n
\n\n \n\n\n";