This commit is contained in:
dekun
2026-05-27 22:35:51 +08:00
parent bb8aca0cb3
commit fe068709ac
10 changed files with 337 additions and 27 deletions
+32 -6
View File
@@ -61,6 +61,8 @@
.pnl-profit{color:#4cd97f;font-weight:600}
.pnl-loss{color:#ff6666;font-weight:600}
.flash{padding:10px;background:#1e2533;color:#4cc2ff;border-radius:10px;margin-bottom:12px;text-align:center;border:1px solid #304164}
form.is-form-submitting{opacity:.88;pointer-events:none}
form.is-form-submitting button[type=submit],form.is-form-submitting input[type=submit]{cursor:wait}
.ai-result{background:#1a1a29;border:1px solid #2e2e45;border-radius:8px;padding:10px;white-space:pre-wrap;max-height:220px;overflow:auto;font-size:.84rem;line-height:1.45;margin-top:8px}
.ai-result.ai-result-md,.detail-modal .panel-body.md-review{white-space:normal}
.ai-result-md p,.detail-modal .panel-body.md-review p{margin:6px 0;color:#dde2ff}
@@ -871,6 +873,7 @@
</div>
<script src="/static/ai_review_render.js?v=1"></script>
<script src="/static/form_submit_guard.js?v=1"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
@@ -1595,28 +1598,36 @@ const keyForm = document.getElementById("key-form");
if(keyForm){
keyForm.addEventListener("submit", (e)=>{
e.preventDefault();
if(window.FormSubmitGuard && FormSubmitGuard.isLocked(keyForm)) return;
const symbolEl = keyForm.querySelector('[name="symbol"]');
const symbol = (symbolEl ? symbolEl.value : "").trim();
if(!symbol){
alert("请先输入交易对");
return;
}
if(window.FormSubmitGuard) FormSubmitGuard.lock(keyForm, "校验排名中…");
fetch(`/api/symbol_liquidity_rank?symbol=${encodeURIComponent(symbol)}`)
.then(r=>r.json().then(d=>({status:r.status, data:d})))
.then(({status,data})=>{
if(status >= 400 || !data.ok){
alert((data && data.msg) || "日成交量排名读取失败");
if(window.FormSubmitGuard) FormSubmitGuard.unlock(keyForm);
return;
}
const rankMax = data.rank_max || 30;
const inTop = data.in_top != null ? data.in_top : data.in_top30;
if(data.rank == null || !inTop){
alert(`${data.symbol} 当前24h成交额排名 ${data.rank == null ? "—" : data.rank}/${data.total},不在前${rankMax},已拦截。`);
if(window.FormSubmitGuard) FormSubmitGuard.unlock(keyForm);
return;
}
keyForm.submit();
if(window.FormSubmitGuard) FormSubmitGuard.nativeSubmitOnce(keyForm, "提交中…");
else keyForm.submit();
})
.catch(()=>alert("日成交量排名检查失败,请稍后重试"));
.catch(()=>{
alert("日成交量排名检查失败,请稍后重试");
if(window.FormSubmitGuard) FormSubmitGuard.unlock(keyForm);
});
});
}
// 复盘/AI列表:初次进入页面后再异步刷新一次,避免浏览器 bfcache/重定向后仍显示旧缓存
@@ -1744,8 +1755,10 @@ function cancelExchangeTpsl(orderId, role){
}
function allowManualOrderSubmit(form){
if(window.FormSubmitGuard && FormSubmitGuard.isLocked(form) && form.dataset.rrOk !== "1") return;
form.dataset.rrOk = "1";
form.submit();
if(window.FormSubmitGuard) FormSubmitGuard.nativeSubmitOnce(form, "开仓提交中…");
else form.submit();
}
let latestAvailableUsdt = null;
@@ -1992,15 +2005,20 @@ if(addOrderForm){
return;
}
ev.preventDefault();
if(window.FormSubmitGuard && FormSubmitGuard.isLocked(addOrderForm)) return;
const direction = (document.getElementById("order-direction")||{}).value || "long";
const mode = (document.getElementById("sltp-mode")||{}).value || "price";
const symbol = ((document.getElementById("order-symbol")||{}).value || "").trim();
if(mode === "pct"){
if(window.FormSubmitGuard) FormSubmitGuard.lock(addOrderForm, "校验盈亏比…");
const rr = calcClientRrFromPct(
(document.getElementById("order-sl-pct")||{}).value,
(document.getElementById("order-tp-pct")||{}).value
);
if(rejectManualOrderRr(rr)) return;
if(rejectManualOrderRr(rr)){
if(window.FormSubmitGuard) FormSubmitGuard.unlock(addOrderForm);
return;
}
allowManualOrderSubmit(addOrderForm);
return;
}
@@ -2010,6 +2028,7 @@ if(addOrderForm){
alert("请先填写币种,以便按市价校验盈亏比");
return;
}
if(window.FormSubmitGuard) FormSubmitGuard.lock(addOrderForm, "校验盈亏比…");
fetch(`/api/order_defaults?symbol=${encodeURIComponent(symbol)}&direction=${encodeURIComponent(direction)}`)
.then(r=>r.json())
.then(data=>{
@@ -2017,12 +2036,19 @@ if(addOrderForm){
const entry = Number(px);
if(!Number.isFinite(entry) || entry <= 0){
alert("无法获取市价,请稍后重试");
if(window.FormSubmitGuard) FormSubmitGuard.unlock(addOrderForm);
return;
}
if(rejectManualOrderRr(calcClientRr(direction, entry, sl, tp))){
if(window.FormSubmitGuard) FormSubmitGuard.unlock(addOrderForm);
return;
}
if(rejectManualOrderRr(calcClientRr(direction, entry, sl, tp))) return;
allowManualOrderSubmit(addOrderForm);
})
.catch(()=>{ alert("无法校验盈亏比,请稍后重试"); });
.catch(()=>{
alert("无法校验盈亏比,请稍后重试");
if(window.FormSubmitGuard) FormSubmitGuard.unlock(addOrderForm);
});
});
}