Auto-size hub order popup iframe so trade form shows without scrollbars.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 23:22:49 +08:00
parent 1767566951
commit 95d5469d12
7 changed files with 105 additions and 33 deletions
+25 -1
View File
@@ -458,12 +458,30 @@
modal.classList.toggle("is-loading", !!loading);
}
function applyOrderPopupFrameHeight(height) {
const frame = document.getElementById("order-popup-frame");
const wrap = document.querySelector(".order-popup-frame-wrap");
if (!frame || !wrap) return;
const maxH = Math.max(320, window.innerHeight - 96);
const h = Math.min(Math.max(Number(height) || 0, 320), maxH);
frame.style.height = h + "px";
wrap.style.height = h + "px";
}
function resetOrderPopupFrameHeight() {
const frame = document.getElementById("order-popup-frame");
const wrap = document.querySelector(".order-popup-frame-wrap");
if (frame) frame.style.height = "";
if (wrap) wrap.style.height = "";
}
function closeOrderPopup() {
const modal = document.getElementById("order-popup-modal");
const frame = document.getElementById("order-popup-frame");
orderPopupUrl = "";
orderPopupCtx = null;
if (frame) frame.src = "about:blank";
resetOrderPopupFrameHeight();
if (modal) {
modal.classList.add("hidden");
modal.setAttribute("aria-hidden", "true");
@@ -556,7 +574,13 @@
window.__hubOrderPopupMsgBound = true;
window.addEventListener("message", (ev) => {
const d = ev.data;
if (!d || d.type !== "hub-order-popup-done") return;
if (!d || typeof d !== "object") return;
if (d.type === "hub-order-popup-resize") {
applyOrderPopupFrameHeight(d.height);
setOrderPopupLoading(false);
return;
}
if (d.type !== "hub-order-popup-done") return;
refreshMonitorBoardNow();
showToast(
d.message || (d.ok ? "开仓请求已提交,请查看监控区" : "开仓提交可能失败,请查看表单提示"),