diff --git a/scripts/sync_strategy_switch_page_asset.py b/scripts/sync_strategy_switch_page_asset.py
index ca4b28a..9a9a74f 100644
--- a/scripts/sync_strategy_switch_page_asset.py
+++ b/scripts/sync_strategy_switch_page_asset.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-"""Embed the strategy switch Worker HTML as a module asset."""
+"""Sync page_asset.js from index.html AND inject platform-config into index.html."""
from __future__ import annotations
@@ -10,24 +10,104 @@
ROOT = Path(__file__).resolve().parents[1]
SOURCE = ROOT / "web" / "strategy-switch-console" / "index.html"
TARGET = ROOT / "web" / "strategy-switch-console" / "page_asset.js"
-PROFILE_SOURCE = ROOT / "web" / "strategy-switch-console" / "strategy-profiles.example.json"
-PROFILE_TARGET = ROOT / "web" / "strategy-switch-console" / "strategy_profiles_asset.js"
+CONFIG_SOURCE = ROOT / "platform-config.json"
+
+
+def inject_platform_config():
+ """Inject ",
+ ])
+
+ html = SOURCE.read_text(encoding="utf-8")
+ existing_start = html.find('', existing_start) + 9
+ html = html[:existing_start] + block + html[existing_end:]
+ else:
+ head_end = html.find('')
+ html = html[:head_end] + "\n" + block + "\n" + html[head_end:]
+
+ SOURCE.write_text(html, encoding="utf-8")
+ print(f"Injected platform-config into index.html")
def main() -> int:
+ # Step 1: Inject config into index.html
+ inject_platform_config()
+
+ # Step 2: Generate page_asset.js from (updated) index.html
html = SOURCE.read_text(encoding="utf-8")
page_payload = (
"// Generated by scripts/sync_strategy_switch_page_asset.py; do not edit by hand.\n"
f"export const PAGE_HTML = {json.dumps(html, ensure_ascii=False)};\n"
)
TARGET.write_text(page_payload, encoding="utf-8")
-
- profiles = json.loads(PROFILE_SOURCE.read_text(encoding="utf-8"))
- profile_payload = (
- "// Generated by scripts/sync_strategy_switch_page_asset.py; do not edit by hand.\n"
- f"export const DEFAULT_STRATEGY_PROFILES = {json.dumps(profiles, ensure_ascii=False)};\n"
- )
- PROFILE_TARGET.write_text(profile_payload, encoding="utf-8")
+ print(f"Generated: {TARGET}")
return 0
diff --git a/web/strategy-switch-console/index.html b/web/strategy-switch-console/index.html
index 203caf0..b330801 100644
--- a/web/strategy-switch-console/index.html
+++ b/web/strategy-switch-console/index.html
@@ -1317,6 +1317,16 @@
}
}
+
+
+
+
@@ -2769,7 +2779,25 @@ 切换摘要
const entry = byPlatform[key];
if (currentEntryHasState(entry)) return entry;
}
- return null;
+ // Build synthetic entry from global defaults when Worker has no data
+ const globalDefaults = window.__DEFAULT_ACCOUNT_OPTIONS__?.[platform]?.[0] || {};
+ const merged = { ...globalDefaults, ...(account || {}) };
+ const profile = cleanStrategyProfile(merged.default_strategy_profile || merged.strategy_profile || "");
+ const synth = {
+ strategy_profile: profile || merged.default_strategy_profile || "",
+ source: "account_defaults",
+ };
+ const cashMode = merged.cash_only_execution_mode;
+ if (cashMode === "enabled") synth.cash_only_execution = true;
+ else if (cashMode === "disabled") synth.cash_only_execution = false;
+ else if (platformSupportsMarginPolicy(platform)) synth.cash_only_execution = true;
+ if (merged.min_reserved_cash_usd) synth.min_reserved_cash_usd = merged.min_reserved_cash_usd;
+ if (merged.reserved_cash_ratio) synth.reserved_cash_ratio = merged.reserved_cash_ratio;
+ synth.runtime_target_enabled = merged.runtime_target_enabled !== false;
+ const execMode = merged.default_execution_mode || platformConfig[platform]?.default_execution_mode || "live";
+ synth.execution_mode = execMode;
+ synth.dry_run_only = execMode === "paper";
+ return synth;
}
function currentEntryHasState(entry) {
@@ -2793,10 +2821,13 @@ 切换摘要
function currentStrategyForAccount(platform, account) {
const entry = currentEntryForAccount(platform, account);
- const profile = cleanStrategyProfile(entry?.strategy_profile);
- if (profile) return profile;
- const fallback = account?.default_strategy_profile || account?.strategy_profile || "";
- return cleanStrategyProfile(fallback);
+ const p = cleanStrategyProfile(entry?.strategy_profile);
+ if (p) return p;
+ const fb = account?.default_strategy_profile
+ || account?.strategy_profile
+ || (window.__DEFAULT_ACCOUNT_OPTIONS__?.[platform]?.[0]?.default_strategy_profile)
+ || "";
+ return cleanStrategyProfile(fb);
}
function currentReservePolicyForAccount(platform, account) {
diff --git a/web/strategy-switch-console/page_asset.js b/web/strategy-switch-console/page_asset.js
index aaa9413..73fbb93 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\n
\n
\n GitHub OAuth 保护\n 只允许白名单账号进入私有配置。\n
\n
\n Worker 端触发\n 令牌保留在服务端,浏览器只提交切换意图。\n
\n
\n 变更可回溯\n 切换由 GitHub Actions 执行,便于审计和回滚。\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 \n
\n\n
登录后查看账号配置。
\n\n
\n
\n GitHub OAuth 保护\n 只允许白名单账号进入私有配置。\n
\n
\n Worker 端触发\n 令牌保留在服务端,浏览器只提交切换意图。\n
\n
\n 变更可回溯\n 切换由 GitHub Actions 执行,便于审计和回滚。\n
\n
\n\n
\n\n
\n
\n
登录后才可执行切换。
\n
\n
\n
\n\n \n \n \n\n \n\n\n";