diff --git a/hub_bridge.py b/hub_bridge.py index 07433a2..86b6bdd 100644 --- a/hub_bridge.py +++ b/hub_bridge.py @@ -823,10 +823,18 @@ def register_hub_routes(app): token = (request.args.get("token") or "").strip() ok, next_path, err = verify_hub_sso_token(token, ex) if ok: - dest_next = _embed_login_dest(next_path) if request.args.get( - "embed", "" - ).strip().lower() in ("1", "true", "yes", "on") else next_path - if _sso_wants_embed_auth() and request.is_secure: + embed_on = request.args.get("embed", "").strip().lower() in ( + "1", + "true", + "yes", + "on", + ) + dest_next = _embed_login_dest(next_path) if embed_on else next_path + if not embed_on: + ht = (request.args.get("hub_theme") or "").strip().lower() + if ht in ("light", "dark"): + dest_next = _merge_query_into_path(next_path, hub_theme=ht) + if embed_on and _sso_wants_embed_auth() and request.is_secure: boot = mint_hub_embed_bootstrap(ex, dest_next) if boot: from urllib.parse import urlencode as _ue @@ -838,7 +846,7 @@ def register_hub_routes(app): return redirect(f"/hub-embed-auth?{_ue(qdict)}") session["logged_in"] = True session.modified = True - return redirect(_embed_login_dest(next_path)) + return redirect(dest_next) hint = err or "校验失败" flash( f"中控 SSO 未生效({hint})。" diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js index e57b2af..9153b1c 100644 --- a/manual_trading_hub/static/app.js +++ b/manual_trading_hub/static/app.js @@ -418,7 +418,7 @@ const next = nextPath || "/"; const q = new URLSearchParams({ exchange_id: String(exchangeId), next }); if (options.embed) q.set("embed", "1"); - if (globalThis.HubTheme && typeof HubTheme.get === "function") { + if (options.embed && globalThis.HubTheme && typeof HubTheme.get === "function") { q.set("hub_theme", HubTheme.get()); } const r = await apiFetch("/api/instance/open-url?" + q.toString()); @@ -456,7 +456,7 @@ try { const embedded = isHubEmbedded(); const url = await fetchInstanceOpenUrl(exchangeId, next, { - embed: embedded || !newTab, + embed: !newTab, }); if (newTab) { window.open(url, "_blank", "noopener");