Add hub order popup modal with compact instance trade embed (plan A).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 23:12:08 +08:00
parent ee011800e1
commit 1767566951
9 changed files with 334 additions and 12 deletions
+43
View File
@@ -0,0 +1,43 @@
/* 中控弹窗 iframe:仅保留实盘下单表单区 */
body[data-order-popup="1"] {
overflow-x: hidden;
}
body[data-order-popup="1"] .container.embed-order-popup-shell {
max-width: 100%;
padding: 10px 12px 16px;
}
body[data-order-popup="1"] .embed-order-popup-head {
margin-bottom: 8px;
}
body[data-order-popup="1"] .embed-order-popup-head h1 {
font-size: 1rem;
margin: 0;
}
body[data-order-popup="1"] .header-row {
margin-top: 6px;
}
body[data-order-popup="1"] .embed-order-popup-hide {
display: none !important;
}
body[data-order-popup="1"] .order-popup-trade-grid {
display: block;
grid-template-columns: 1fr;
}
body[data-order-popup="1"] .order-popup-form-card {
margin: 0;
}
body[data-order-popup="1"] .order-popup-form-card h2 {
font-size: 0.95rem;
}
body[data-order-popup="1"] .order-popup-form-card > div:first-child span.btn-del {
display: none;
}
+43 -2
View File
@@ -17,6 +17,35 @@
/** 自带校验后 form.submit() 的表单,勿在捕获阶段再 fetch 一份(会双发 POST */
const CUSTOM_SUBMIT_FORM_IDS = new Set(["add-order-form", "key-form"]);
function isOrderPopup() {
return document.body && document.body.getAttribute("data-order-popup") === "1";
}
function notifyOrderPopupParent(ok, message) {
if (!isOrderPopup()) return;
try {
window.parent.postMessage(
{
type: "hub-order-popup-done",
ok: !!ok,
message: message || "",
},
"*"
);
} catch (_) {}
}
function prefillOrderSymbolFromQuery() {
if (!isOrderPopup()) return;
let sym = "";
try {
sym = (new URLSearchParams(location.search).get("symbol") || "").trim();
} catch (_) {}
if (!sym) return;
const el = document.getElementById("order-symbol");
if (el && !String(el.value || "").trim()) el.value = sym;
}
function isEmbedShell() {
return document.body && document.body.getAttribute("data-embed-shell") === "1";
}
@@ -67,6 +96,7 @@
if (global.ManualOrderRrPreview && typeof global.ManualOrderRrPreview.wire === "function") {
global.ManualOrderRrPreview.wire();
}
prefillOrderSymbolFromQuery();
}
if (tab === "key_monitor" && global.KeyMonitorForm && typeof global.KeyMonitorForm.init === "function") {
global.KeyMonitorForm.init();
@@ -140,14 +170,25 @@
}
}
const fd = new FormData(form);
const isOrderForm = form.id === "add-order-form";
return fetch(form.action, {
method: form.method || "POST",
body: fd,
credentials: "same-origin",
redirect: "manual",
})
.then(() => reloadCurrentTab())
.catch(() => reloadCurrentTab());
.then((resp) => {
if (isOrderForm && isOrderPopup()) {
notifyOrderPopupParent(resp.ok || resp.type === "opaqueredirect", "");
}
return reloadCurrentTab();
})
.catch((err) => {
if (isOrderForm && isOrderPopup()) {
notifyOrderPopupParent(false, String(err && err.message ? err.message : err));
}
return reloadCurrentTab();
});
}
function patchApplyListWindow() {