diff --git a/lib/instance/instance_embed_lib.py b/lib/instance/instance_embed_lib.py index f0b8e45..29e1f4c 100644 --- a/lib/instance/instance_embed_lib.py +++ b/lib/instance/instance_embed_lib.py @@ -220,10 +220,19 @@ def pwa_app_name(exchange_key: str) -> str: def embed_context_extras(exchange_key: str) -> dict: + # 顶栏共享模板调用 trading_account_label / options_funding_label; + # 须注入三所,否则 Gate/Binance 渲染会 UndefinedError → HTTP 500. + from lib.instance.instance_embed_context_lib import ( + options_funding_label, + trading_account_label, + ) + return { "order_rule_tips_tpl": order_rule_tips_template(exchange_key), "include_transfer_block": include_transfer_block(exchange_key), "ui_open_guard_enabled": ui_open_guard_enabled(exchange_key), "ui_orphan_recovery_enabled": ui_orphan_recovery_enabled(exchange_key), "pwa_app_name": pwa_app_name(exchange_key), + "options_funding_label": options_funding_label, + "trading_account_label": trading_account_label, } diff --git a/lib/instance/templates/embed_boot_scripts.html b/lib/instance/templates/embed_boot_scripts.html index 1058e24..b9f70b0 100644 --- a/lib/instance/templates/embed_boot_scripts.html +++ b/lib/instance/templates/embed_boot_scripts.html @@ -1143,7 +1143,8 @@ function formatOptionsFundingLabel(usdc, usdt, eth, marginMode, underly) { return `${n.toFixed(2)} USDC`; } function formatTradingAccountLabel(usdt, eth, btc, marginMode) { - const mode = String(marginMode || "coin").toLowerCase(); + // 缺省按 usdc(xx.xxU):Gate/Binance 快照无 options_margin_mode;OKX 会显式下发. + const mode = String(marginMode || "usdc").toLowerCase(); if (mode !== "coin") { if (usdt === null || usdt === undefined || usdt === "") return "—"; const n = Number(usdt); @@ -1203,7 +1204,7 @@ function accountSnapshotFundingMissing(data){ let accountSnapshotRetryCount = 0; function applyAccountSnapshot(data){ if(!data || typeof data !== "object") return; - const coinMode = String(data.options_margin_mode || "coin").toLowerCase() === "coin"; + const coinMode = String(data.options_margin_mode || "").toLowerCase() === "coin"; if(typeof data.show_perp_funds !== "undefined"){ applyPerpFundsVisibility(data.show_perp_funds !== false || coinMode); } else if (coinMode) { diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index 7d9d409..0730f3b 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -1624,7 +1624,8 @@ function formatOptionsFundingLabel(usdc, usdt, eth, marginMode, underly) { return `${n.toFixed(2)} USDC`; } function formatTradingAccountLabel(usdt, eth, btc, marginMode) { - const mode = String(marginMode || "coin").toLowerCase(); + // 缺省按 usdc(xx.xxU):Gate/Binance 快照无 options_margin_mode;OKX 会显式下发. + const mode = String(marginMode || "usdc").toLowerCase(); if (mode !== "coin") { if (usdt == null || usdt === "") return "—"; const n = Number(usdt); @@ -1684,7 +1685,7 @@ function accountSnapshotFundingMissing(data){ let accountSnapshotRetryCount = 0; function applyAccountSnapshot(data){ if(!data || typeof data !== "object") return; - const coinMode = String(data.options_margin_mode || "coin").toLowerCase() === "coin"; + const coinMode = String(data.options_margin_mode || "").toLowerCase() === "coin"; if(typeof data.show_perp_funds !== "undefined"){ applyPerpFundsVisibility(data.show_perp_funds !== false || coinMode); } else if (coinMode) { diff --git a/lib/instance/templates/instance_header_panel.html b/lib/instance/templates/instance_header_panel.html index 4f3a675..9118bcb 100644 --- a/lib/instance/templates/instance_header_panel.html +++ b/lib/instance/templates/instance_header_panel.html @@ -38,11 +38,12 @@ {% include 'instance_header_stats.html' %}