From b81b999090c4099e0782cd99a3e29486ad3b7292 Mon Sep 17 00:00:00 2001 From: dekun Date: Tue, 13 Oct 2026 14:36:52 +0800 Subject: [PATCH] =?UTF-8?q?feat=E6=9D=A1=E4=BB=B6=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B5=84=E9=87=91=E4=B8=8E=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E6=88=B7=E5=8F=8C=E5=90=91=E5=88=92=E8=BD=AC=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B4=A6=E6=88=B7=E5=90=8D=E8=A2=AB=E6=8C=A4?= =?UTF-8?q?=E5=8D=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- static/cond_orders.js | 72 +++++++++++++++++++++++++++----------- static/hub.css | 46 ++++++++++++++++++------ templates/base.html | 2 +- templates/cond_orders.html | 4 +-- 4 files changed, 90 insertions(+), 34 deletions(-) diff --git a/static/cond_orders.js b/static/cond_orders.js index 54e8e16..bf97ac7 100644 --- a/static/cond_orders.js +++ b/static/cond_orders.js @@ -251,7 +251,7 @@ if (fundEl) fundEl.textContent = "资金 " + fmtTradingU(fundingUsdt); } - function transferFundingToTrading(instanceId) { + function transferInternal(instanceId, direction) { const id = String(instanceId || ""); const it = candidatesById[id]; if (!it) return; @@ -263,31 +263,39 @@ window.alert(it.transfer_block_msg || "当前不可划转"); return; } - const fund = Number(it.funding_usdt); + const toTrading = direction !== "to_funding"; + const fromAcct = toTrading ? "funding" : "trading"; + const toAcct = toTrading ? "trading" : "funding"; + const srcBal = Number(toTrading ? it.funding_usdt : it.trading_usdt); const defAmt = - !Number.isNaN(fund) && fund > 0 ? String(Math.round(fund * 10000) / 10000) : ""; - const raw = window.prompt("资金户 → 交易户(USDT)。本页划转,条件单表单不会丢失。", defAmt); + !Number.isNaN(srcBal) && srcBal > 0 + ? String(Math.round(srcBal * 10000) / 10000) + : ""; + const label = toTrading ? "资金户 → 交易户" : "交易户 → 资金户"; + const raw = window.prompt(label + "(USDT)。本页划转,条件单表单不会丢失。", defAmt); if (raw == null) return; const amount = Number(String(raw).trim()); if (!(amount > 0)) { window.alert("请输入大于 0 的数量"); return; } - const btn = document.querySelector( + const btns = document.querySelectorAll( '.cond-inst-xfer[data-inst-id="' + id.replace(/"/g, "") + '"]' ); - if (btn) { + const labels = []; + btns.forEach(function (btn) { + labels.push(btn.textContent); btn.disabled = true; btn.textContent = "划转中…"; - } + }); fetch("/api/instances/" + encodeURIComponent(id) + "/transfer", { method: "POST", credentials: "same-origin", headers: { "Content-Type": "application/json", Accept: "application/json" }, body: JSON.stringify({ amount: amount, - from: "funding", - to: "trading", + from: fromAcct, + to: toAcct, ccy: "USDT", }), }) @@ -307,10 +315,14 @@ if (st) { st.textContent = (it.name || id) + - " 已划入交易 " + + " " + + label + + " " + fmtTradingU(amount) + "(交易 " + fmtTradingU(d.trading_usdt) + + " / 资金 " + + fmtTradingU(d.funding_usdt) + ")"; } }) @@ -318,10 +330,11 @@ window.alert("划转请求失败"); }) .finally(function () { - if (btn) { - btn.disabled = !!(it.transfer_blocked || !it.online); - btn.textContent = "划入交易"; - } + const blocked = !!(it.transfer_blocked || !it.online); + btns.forEach(function (btn, i) { + btn.disabled = blocked; + btn.textContent = labels[i] || btn.getAttribute("data-label") || "划转"; + }); }); } @@ -341,16 +354,18 @@ const xferBlocked = !!(it.transfer_blocked || !it.online); const xferTitle = xferBlocked ? it.transfer_block_msg || (!it.online ? "离线" : "不可划转") - : "资金户→交易户,本页完成不丢表单"; + : "本页双向划转,表单不丢"; + const dis = xferBlocked ? " disabled" : ""; return ( '
' + - '
" + "" ); } @@ -443,7 +470,10 @@ btn.addEventListener("click", function (ev) { ev.preventDefault(); ev.stopPropagation(); - transferFundingToTrading(btn.getAttribute("data-inst-id") || ""); + transferInternal( + btn.getAttribute("data-inst-id") || "", + btn.getAttribute("data-dir") || "to_trading" + ); }); }); box.querySelectorAll(".cond-inst-open").forEach(function (btn) { diff --git a/static/hub.css b/static/hub.css index 213434e..13d6236 100644 --- a/static/hub.css +++ b/static/hub.css @@ -1524,31 +1524,51 @@ input.readonly { .cond-inst-group-label { margin-bottom: 8px; } .cond-inst-grid { display: grid; - grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; } .cond-inst-row { - display: flex; - align-items: stretch; - gap: 8px; + display: block; + min-width: 0; } .cond-inst-row.is-off { opacity: 0.5; } .cond-inst { display: flex; - align-items: center; - justify-content: space-between; + flex-direction: column; + align-items: stretch; gap: 8px; - flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(8, 16, 30, 0.72); +} +.cond-inst input { width: auto; margin: 0; flex-shrink: 0; } +.cond-inst-head { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; cursor: pointer; } -.cond-inst input { width: auto; margin: 0; } -.cond-inst-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.cond-inst.is-off .cond-inst-head { cursor: not-allowed; } +.cond-inst-name { + flex: 1; + font-weight: 600; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} .cond-inst-tag { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; } +.cond-inst-body { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px 10px; + padding-left: 24px; + min-width: 0; +} .cond-inst-funds { color: var(--accent-2, #38bdf8); font-size: 0.78rem; @@ -1560,10 +1580,16 @@ input.readonly { color: var(--muted); font-weight: 500; } +.cond-inst-actions { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 6px; + margin-left: auto; +} .cond-inst-xfer, .cond-inst-open { flex-shrink: 0; - align-self: center; white-space: nowrap; } .cond-inst.is-off { cursor: not-allowed; } diff --git a/templates/base.html b/templates/base.html index 209af37..3fedc74 100644 --- a/templates/base.html +++ b/templates/base.html @@ -11,7 +11,7 @@ - + + {% endblock %}