网络请求加超时防止卡死,持仓同步限制最近20天,次日预测移出表格
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -245,16 +245,24 @@ function pollProgress() {
|
||||
clearInterval(syncTimer);
|
||||
syncTimer = null;
|
||||
document.getElementById('sync-progress-bar').style.width = '100%';
|
||||
var resultText = data.result > 0 ? ' · +' + data.result : '';
|
||||
document.getElementById('sync-progress-label').textContent = data.label + ' ✓' + resultText;
|
||||
if (data.result > 0) {
|
||||
document.getElementById('sync-progress-label').textContent = data.label + ' ✓ · +' + data.result;
|
||||
} else if (data.total > 0) {
|
||||
document.getElementById('sync-progress-label').textContent = data.label + ' ⚠ 无新数据,历史日期无可用持仓';
|
||||
} else {
|
||||
document.getElementById('sync-progress-label').textContent = data.label + ' ✓ 已是最新';
|
||||
}
|
||||
document.getElementById('sync-progress-pct').textContent = '';
|
||||
// Remember which product headers are expanded before reload
|
||||
var expanded = [];
|
||||
document.querySelectorAll('.product-body').forEach(function(b, i) {
|
||||
if (b.style.display === 'block') expanded.push(i);
|
||||
});
|
||||
try { sessionStorage.setItem('ft-expanded', JSON.stringify(expanded)); } catch(e) {}
|
||||
setTimeout(function() { location.reload(); }, 1200);
|
||||
document.getElementById('sync-progress').insertAdjacentHTML('beforeend',
|
||||
'<button onclick="hideProgress()" style="display:block;margin-top:10px;padding:4px 14px;border:1px solid var(--border);border-radius:5px;background:var(--surface);color:var(--fg);cursor:pointer;font-size:0.8rem;">关闭</button>');
|
||||
if (data.result > 0) {
|
||||
var expanded = [];
|
||||
document.querySelectorAll('.product-body').forEach(function(b, i) {
|
||||
if (b.style.display === 'block') expanded.push(i);
|
||||
});
|
||||
try { sessionStorage.setItem('ft-expanded', JSON.stringify(expanded)); } catch(e) {}
|
||||
setTimeout(function() { location.reload(); }, 1200);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
@@ -317,5 +325,18 @@ function toggleProduct(header) {
|
||||
} catch(e) {}
|
||||
})();
|
||||
|
||||
// Auto-show progress bar if a sync is already running
|
||||
(function() {
|
||||
fetch('/admin/sync-status')
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data.running) {
|
||||
showProgress();
|
||||
syncTimer = setInterval(pollProgress, 500);
|
||||
pollProgress();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user