同步进度增加详细天数反馈,优化日期范围避免重复请求无数据的历史日期

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 14:03:33 +08:00
parent ca98967af0
commit 58327a9a66
2 changed files with 28 additions and 11 deletions
+14 -7
View File
@@ -193,8 +193,10 @@
<script>
var syncTimer = null;
var progressShownAt = 0;
function showProgress() {
progressShownAt = Date.now();
document.getElementById('sync-progress').style.display = 'block';
document.getElementById('sync-progress-bar').style.width = '0%';
document.getElementById('sync-progress-pct').textContent = '';
@@ -203,6 +205,7 @@ function showProgress() {
function hideProgress() {
clearInterval(syncTimer);
syncTimer = null;
document.getElementById('sync-progress').style.display = 'none';
}
@@ -216,23 +219,27 @@ function pollProgress() {
document.getElementById('sync-progress-label').textContent = data.label;
if (data.finished) {
clearInterval(syncTimer);
document.getElementById('sync-progress-bar').style.width = '100%';
document.getElementById('sync-progress-pct').textContent = '100%';
document.getElementById('sync-progress-label').textContent = data.label + ' 完成';
document.getElementById('sync-progress-pct').textContent = '✓';
var elapsed = Date.now() - progressShownAt;
var delay = elapsed < 1000 ? 1000 - elapsed : 0;
setTimeout(function() {
clearInterval(syncTimer);
syncTimer = null;
document.getElementById('sync-progress-bar').style.width = '100%';
document.getElementById('sync-progress-label').textContent = data.label + ' ✓';
document.getElementById('sync-progress-pct').textContent = '';
}, delay);
}
});
}
function startSync(url) {
if (syncTimer) { clearInterval(syncTimer); }
if (syncTimer) { clearInterval(syncTimer); syncTimer = null; }
showProgress();
fetch(url, { method: 'POST' })
.then(function(r) { return r.json(); })
.then(function(data) {
if (!data.ok) { hideProgress(); return; }
syncTimer = setInterval(pollProgress, 600);
syncTimer = setInterval(pollProgress, 500);
});
}