From b0c331aa2656e5b25de150e663f3bc81b8e70ed0 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 20 Aug 2026 14:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B8=81=E6=9C=AC=E4=BD=8D?= =?UTF-8?q?=E9=A1=B6=E6=A0=8F=E6=94=B9=E5=8A=A8=E5=AF=BC=E8=87=B4=20Gate/B?= =?UTF-8?q?inance=20=E9=A1=B6=E6=A0=8F=20UndefinedError=20500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/instance/instance_embed_lib.py | 9 +++++++++ lib/instance/templates/embed_boot_scripts.html | 5 +++-- lib/instance/templates/index.html | 5 +++-- lib/instance/templates/instance_header_panel.html | 5 +++-- lib/instance/templates/instance_header_stats.html | 6 ++++-- 5 files changed, 22 insertions(+), 8 deletions(-) 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' %}
- {% set _coin_margin = (options_margin_mode|default('coin')) == 'coin' %} + {% set _coin_margin = (options_enabled|default(false)) and (options_margin_mode|default('coin')) == 'coin' %} {% set _show_perp = (show_perp_funds|default(true)) or _coin_margin %} + {% set _trading_margin_mode = 'coin' if _coin_margin else 'usdc' %}