Add PostgreSQL production backend to eliminate SQLite lock contention.

Support DATABASE_URL with connection pooling, pg_dump backups, SQLite migration script, and deploy_postgres.sh with docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-01 08:11:42 +08:00
parent 39eac983ff
commit 52aca456e9
23 changed files with 1208 additions and 150 deletions
+7 -2
View File
@@ -859,8 +859,13 @@
equityEl.textContent = fmtMoney(data.capital);
}
var rows = positionRows(data);
if (!rows.length && data.sync_state === 'syncing' && lastPosRows.length) {
rows = lastPosRows;
if (!rows.length && lastPosRows.length) {
var keepSticky = data.sync_state === 'syncing'
|| Number(data.margin_used) > 0
|| (data.risk_status && Number(data.risk_status.active_count) > 0);
if (keepSticky) {
rows = lastPosRows;
}
}
var sig = rows.map(function (r) {
var key = r.key || r.position_key || ((r.symbol_code || '') + ':' + (r.direction || ''));
+5 -3
View File
@@ -331,7 +331,9 @@
}
var syncing = data.sync_state === 'syncing';
var hadPos = lastPosRowCount > 0 || !!list.querySelector('.pos-card');
if (syncing || hadPos) {
var marginOpen = Number(data.margin_used) > 0;
var riskActive = data.risk_status && Number(data.risk_status.active_count) > 0;
if (syncing || hadPos || marginOpen || riskActive) {
if (syncBadge) {
syncBadge.hidden = false;
syncBadge.textContent = data.sync_label || '持仓同步中…';
@@ -543,8 +545,8 @@
var hint = document.getElementById('ctp-auto-hint');
if (hint) {
hint.textContent = ctpAutoConnectEnabled
? '断线自动重连 · 开盘前 30 分钟自动连接'
: '自动连接已关闭 · 盘前 30 分钟仍会按计划连接';
? '交易时段断线自动重连 · 开盘前 30 分钟检查连接 · 不自动强制断开'
: '自动连接已关闭 · 盘前 30 分钟及交易时段仍会按计划连接 · 断开请手动操作';
}
if (btnConnect && !ctpAutoConnectEnabled) {
btnConnect.disabled = true;