Add hub iframe embed shell with tab fragment API.
Replace full-page soft nav with a persistent shell and /api/embed/page loads so tab switches in the hub iframe avoid document.write flicker. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6828,7 +6828,7 @@ def fetch_binance_net_pnl_for_trade(
|
||||
|
||||
|
||||
# ====================== 主页面 ======================
|
||||
def render_main_page(page="trade"):
|
||||
def render_main_page(page="trade", embed_mode=None):
|
||||
now = app_now()
|
||||
trading_day = get_trading_day(now)
|
||||
list_window = _list_window_from_request()
|
||||
@@ -6909,8 +6909,9 @@ def render_main_page(page="trade"):
|
||||
if not order_list and exchange_private_api_configured():
|
||||
orphan_live_positions = list_orphan_live_positions(conn)
|
||||
conn.close()
|
||||
return render_template(
|
||||
"index.html",
|
||||
from instance_embed_lib import embed_context_extras
|
||||
|
||||
template_ctx = dict(
|
||||
page=page,
|
||||
key=key_list,
|
||||
key_history=key_history,
|
||||
@@ -6979,7 +6980,13 @@ def render_main_page(page="trade"):
|
||||
key_rule_ctx=key_rule_ctx,
|
||||
kline_timeframe=KLINE_TIMEFRAME,
|
||||
**strategy_extra,
|
||||
**embed_context_extras("binance"),
|
||||
)
|
||||
if embed_mode == "fragment":
|
||||
return render_template("embed_page_fragment.html", **template_ctx)
|
||||
if embed_mode == "shell":
|
||||
return render_template("embed_shell.html", initial_tab=page, **template_ctx)
|
||||
return render_template("index.html", **template_ctx)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@@ -9375,6 +9382,8 @@ try:
|
||||
market_fn=_hub_fetch_market,
|
||||
risk_status_fn=hub_account_risk_status,
|
||||
user_close_fn=hub_user_initiated_close,
|
||||
render_main_page_fn=render_main_page,
|
||||
login_required_fn=login_required,
|
||||
)
|
||||
except Exception as _hub_err:
|
||||
print(f"[hub_bridge] binance: {_hub_err}")
|
||||
|
||||
Reference in New Issue
Block a user