修复读取

This commit is contained in:
dekun
2026-05-17 17:12:02 +08:00
parent 56f58c2b52
commit a250c28ceb
2 changed files with 106 additions and 35 deletions
+28
View File
@@ -493,6 +493,16 @@
{% if page == 'records' %}
<div class="card full records-card">
<h2>交易记录 & 错过机会</h2>
<div class="rule-tip" style="margin-bottom:8px;font-size:.78rem">
盈亏U:<span style="color:#6ab88a"></span>=交易所平仓历史,
<span style="color:#8892b0"></span>=本地估算。
{% if exchange_pnl_sync %}
{% if exchange_pnl_sync.skipped %}25秒内已同步,可点右侧按钮强制){% else %}
本轮:平仓历史 {{ exchange_pnl_sync.hist_count or 0 }} 条,对齐 {{ exchange_pnl_sync.matched or 0 }} 笔{% if exchange_pnl_sync.reason %} — {{ exchange_pnl_sync.reason }}{% endif %}
{% endif %}
{% endif %}
<button type="button" id="sync-exchange-pnl-btn" style="margin-left:8px;padding:4px 10px;background:#1f3a5a;color:#8fc8ff;border:none;border-radius:6px;cursor:pointer">立即同步</button>
</div>
<div class="form-row" style="margin-bottom:10px;gap:8px">
<label style="display:flex;align-items:center;gap:6px;font-size:.82rem;color:#cfd3ef">
<input id="review-mode-toggle" type="checkbox">
@@ -1704,6 +1714,24 @@ function refreshPriceSnapshotConditional(){
}).catch(()=>{});
}
setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }});
const syncExchangePnlBtn = document.getElementById("sync-exchange-pnl-btn");
if(syncExchangePnlBtn){
syncExchangePnlBtn.addEventListener("click", ()=>{
syncExchangePnlBtn.disabled = true;
syncExchangePnlBtn.innerText = "同步中…";
fetch("/api/sync_exchange_pnl").then(r=>r.json()).then(data=>{
const msg = data.ok
? `平仓历史 ${data.hist_count||0} 条,对齐 ${data.matched||0}${data.reason?("\n"+data.reason):""}`
: (data.reason || "同步失败");
alert(msg);
if((data.matched||0) > 0) location.reload();
}).catch(()=>alert("同步请求失败")).finally(()=>{
syncExchangePnlBtn.disabled = false;
syncExchangePnlBtn.innerText = "立即同步";
});
});
}
</script>
</body>
</html>