Fix order_popup flag through SSO and hide stats in hub order popup.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1900,8 +1900,12 @@ def api_instance_open_url(
|
||||
next: str = "/",
|
||||
embed: str = "",
|
||||
hub_theme: str = "",
|
||||
order_popup: str = "",
|
||||
symbol: str = "",
|
||||
):
|
||||
"""已登录中控时生成实例 SSO 打开链接(2h 有效、单次使用,复用 HUB_BRIDGE_TOKEN)。"""
|
||||
from instance_embed_lib import merge_next_query
|
||||
|
||||
_require_hub_logged_in(request)
|
||||
if not HUB_BRIDGE_TOKEN:
|
||||
raise HTTPException(status_code=503, detail="未配置 HUB_BRIDGE_TOKEN,无法签发实例打开链接")
|
||||
@@ -1915,6 +1919,11 @@ def api_instance_open_url(
|
||||
if not ex_key:
|
||||
raise HTTPException(status_code=400, detail="该账户缺少 key(用于 SSO 校验)")
|
||||
nxt = safe_next_path(next)
|
||||
if (order_popup or "").strip().lower() in ("1", "true", "yes", "on"):
|
||||
nxt = merge_next_query(nxt, order_popup="1")
|
||||
sym = (symbol or "").strip()
|
||||
if sym:
|
||||
nxt = merge_next_query(nxt, symbol=sym)
|
||||
token = mint_hub_sso_token(ex_key, nxt)
|
||||
if not token:
|
||||
raise HTTPException(status_code=503, detail="签发 SSO 失败")
|
||||
|
||||
@@ -419,8 +419,12 @@
|
||||
async function fetchInstanceOpenUrl(exchangeId, nextPath, opts) {
|
||||
const options = opts || {};
|
||||
const next = nextPath || "/";
|
||||
const q = new URLSearchParams({ exchange_id: String(exchangeId), next });
|
||||
const q = new URLSearchParams();
|
||||
q.set("exchange_id", String(exchangeId));
|
||||
q.set("next", next);
|
||||
if (options.embed) q.set("embed", "1");
|
||||
if (options.orderPopup) q.set("order_popup", "1");
|
||||
if (options.symbol) q.set("symbol", String(options.symbol));
|
||||
if (options.embed && globalThis.HubTheme && typeof HubTheme.get === "function") {
|
||||
q.set("hub_theme", HubTheme.get());
|
||||
}
|
||||
@@ -493,10 +497,12 @@
|
||||
async function openOrderPopup(exchangeId, opts) {
|
||||
const options = opts || {};
|
||||
const symbol = (options.symbol || "").trim();
|
||||
let next = "/trade?order_popup=1";
|
||||
if (symbol) next += "&symbol=" + encodeURIComponent(symbol);
|
||||
try {
|
||||
const url = await fetchInstanceOpenUrl(exchangeId, next, { embed: true });
|
||||
const url = await fetchInstanceOpenUrl(exchangeId, "/trade", {
|
||||
embed: true,
|
||||
orderPopup: true,
|
||||
symbol: symbol || undefined,
|
||||
});
|
||||
const row = lastMonitorRows.find((x) => String(x.id) === String(exchangeId));
|
||||
const title = row ? row.name : exchangeId;
|
||||
orderPopupCtx = { exchangeId: String(exchangeId), title, symbol };
|
||||
@@ -539,11 +545,11 @@
|
||||
const frame = document.getElementById("order-popup-frame");
|
||||
if (!frame) return;
|
||||
try {
|
||||
let next = "/trade?order_popup=1";
|
||||
if (orderPopupCtx.symbol) {
|
||||
next += "&symbol=" + encodeURIComponent(orderPopupCtx.symbol);
|
||||
}
|
||||
const url = await fetchInstanceOpenUrl(orderPopupCtx.exchangeId, next, { embed: true });
|
||||
const url = await fetchInstanceOpenUrl(orderPopupCtx.exchangeId, "/trade", {
|
||||
embed: true,
|
||||
orderPopup: true,
|
||||
symbol: orderPopupCtx.symbol || undefined,
|
||||
});
|
||||
orderPopupUrl = url;
|
||||
setOrderPopupLoading(true);
|
||||
frame.src = url;
|
||||
|
||||
Reference in New Issue
Block a user