Fix UI stuck after manual close: fast API return and closing state instead of SL/TP revive.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-03 21:54:35 +08:00
parent b888a670b6
commit f2bd76d970
2 changed files with 83 additions and 9 deletions
+28 -1
View File
@@ -1232,10 +1232,32 @@
);
}
function buildClosingCard(row) {
var dirBadge = row.direction_label || (row.direction === 'long' ? '做多' : '做空');
var openT = (row.open_time || '').replace('T', ' ').slice(0, 16);
return (
'<div class="pos-card pos-card-closing">' +
'<div class="pos-card-head"><div><div class="title">' + posSymbolTitleHtml(row,
' <span class="badge dir">' + dirBadge + '</span>') + '</div>' +
'<div class="text-muted pos-symbol-sub">' + posSymbolSubHtml(row) + '</div></div></div>' +
'<div class="pos-card-meta pos-card-meta-line">来源 <strong>' +
(row.source_label || '平仓处理中') + '</strong> · <span class="text-accent">平仓委托已提交,等待柜台成交…</span></div>' +
'<div class="pos-metrics">' +
'<div class="cell"><label>手数</label><div><strong>' + row.lots + ' 手</strong></div></div>' +
'<div class="cell"><label>均价</label><div>' + fmtNum(row.entry_price) + '</div></div>' +
'<div class="cell"><label>当前价格</label><div>' + (row.current_price != null ? fmtNum(row.current_price) : '--') + '</div></div>' +
'<div class="cell"><label>开仓</label><div>' + (openT || '--') + '</div></div>' +
'</div></div>'
);
}
function buildPosCard(row) {
if (row.order_state === 'pending') {
return buildPendingOrderCard(row);
}
if (row.order_state === 'closing') {
return buildClosingCard(row);
}
var pnlClass = row.float_pnl > 0 ? 'pnl-pos' : (row.float_pnl < 0 ? 'pnl-neg' : '');
var pnlText = row.float_pnl != null ? ((row.float_pnl >= 0 ? '+' : '') + fmtNum(row.float_pnl) + ' 元') : '--';
var dirBadge = row.direction_label || (row.direction === 'long' ? '做多' : '做空');
@@ -1529,9 +1551,14 @@
}
return;
}
if (btn) btn.textContent = '已平仓';
if (btn) {
btn.disabled = true;
btn.textContent = '平仓中…';
}
startPosFastPoll(90);
pollPositions();
}).catch(function () {
alert('平仓请求失败,请查看持仓是否已变化');
if (btn) {
btn.disabled = false;
btn.textContent = '平仓';