读取策略配置
+正在读取登录状态、账号配置和当前状态。
+ +切换摘要
zh: { appTitle: "策略切换", appSubtitle: "选平台、目标账号和策略,一次执行完成切换。", + bootKicker: "初始化控制台", + bootTitle: "读取策略配置", + bootMessage: "正在读取登录状态、账号配置和当前状态。", + bootStrategy: "正在读取策略目录。", + bootSession: "正在验证登录状态。", + bootConfig: "正在读取账号配置和当前状态。", + bootPublic: "公开预览已就绪。", login: "登录", logout: "退出", signedInAs: "已登录 {login}", @@ -787,6 +888,13 @@切换摘要
en: { appTitle: "Strategy Switch", appSubtitle: "Pick platform, target account, and strategy. One action switches everything.", + bootKicker: "Starting console", + bootTitle: "Loading strategy config", + bootMessage: "Reading session, account config, and current state.", + bootStrategy: "Reading strategy catalog.", + bootSession: "Checking sign-in status.", + bootConfig: "Reading account config and current state.", + bootPublic: "Public preview is ready.", login: "Sign in", logout: "Sign out", signedInAs: "Signed in as {login}", @@ -848,6 +956,8 @@切换摘要
const state = { selected: "longbridge", lang: initialLang, + appReady: false, + bootMessageKey: "bootMessage", auth: { available: false, allowed: false, admin: false, login: null }, accountOptions: clone(defaultAccountOptions), currentStrategies: {}, @@ -1263,15 +1373,23 @@切换摘要
note.classList.toggle("warning", state.auth.allowed && !loadingConfig && (!hasPrivateAccounts || !hasValidStrategy)); } + function renderAppVisibility() { + document.body.classList.toggle("app-loading", !state.appReady); + el("boot-message").textContent = t(state.bootMessageKey); + } + function render() { applyLanguage(); renderPlatforms(); renderControls(); renderSummary(); renderAuth(); + renderAppVisibility(); } async function refreshSession() { + state.bootMessageKey = "bootSession"; + render(); try { const response = await fetch("/api/session", { cache: "no-store" }); if (!response.ok) throw new Error("no backend"); @@ -1285,11 +1403,18 @@切换摘要
} catch { state.auth = { available: false, allowed: false, admin: false, login: null }; } - render(); - await refreshConfig(); + if (state.auth.allowed) { + await refreshConfig(); + } else { + state.bootMessageKey = "bootPublic"; + state.appReady = true; + render(); + } } async function refreshStrategyProfiles() { + state.bootMessageKey = "bootStrategy"; + render(); try { const response = await fetch("/api/strategy-profiles", { cache: "no-store" }); if (!response.ok) throw new Error("no strategy profiles"); @@ -1306,6 +1431,7 @@切换摘要
async function refreshConfig() { if (!state.auth.available || !state.auth.allowed) return; state.configSource = "loading"; + state.bootMessageKey = "bootConfig"; render(); try { const response = await fetch("/api/config", { cache: "no-store" }); @@ -1320,11 +1446,16 @@切换摘要
ensureAccountSelection(platform); syncStrategyForAccount(platform); } - render(); + } else { + state.configSource = "default"; + state.currentStrategies = {}; } } catch { state.configSource = "default"; state.currentStrategies = {}; + } finally { + state.appReady = true; + render(); } } @@ -1454,8 +1585,12 @@切换摘要
applyStrategyProfiles(defaultStrategyProfiles); for (const platform of Object.keys(platformMeta)) syncStrategyForAccount(platform); render(); - refreshStrategyProfiles(); - refreshSession(); + boot(); + + async function boot() { + await refreshStrategyProfiles(); + await refreshSession(); + } diff --git a/web/strategy-switch-console/page_asset.js b/web/strategy-switch-console/page_asset.js index e68cea5..d70542e 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策略切换
\n选平台、目标账号和策略,一次执行完成切换。
\nLongBridge
\n登录后才可执行切换。
\n \n策略切换
\n选平台、目标账号和策略,一次执行完成切换。
\n读取策略配置
\n正在读取登录状态、账号配置和当前状态。
\n \nLongBridge
\n登录后才可执行切换。
\n \n