网络请求加超时防止卡死,持仓同步限制最近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 %}
|
||||
|
||||
@@ -13,21 +13,18 @@
|
||||
<span style="font-size:0.78rem;color:var(--sub);">共 {{ total_rows }} 条</span>
|
||||
</div>
|
||||
|
||||
{% if page == 1 and next_date %}
|
||||
<div style="background:var(--accent-light);border:1px solid var(--accent);border-radius:8px;padding:12px 18px;margin-bottom:14px;display:flex;align-items:center;gap:16px;">
|
||||
<span style="font-size:0.78rem;color:var(--sub);">📅 次日预测</span>
|
||||
<span style="font-weight:600;">{{ next_date }} {{ next_weekday }}</span>
|
||||
<span style="color:var(--sub);">预计振幅</span>
|
||||
<span class="amp-cell" style="color:var(--accent);font-weight:700;font-size:1.1rem;cursor:pointer;" data-next="1">{{ next_amp }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="table-wrap">
|
||||
<table id="bars-table">
|
||||
<tr><th>日期</th><th>星期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>波幅</th><th>5日均振幅</th></tr>
|
||||
{% if page == 1 and next_date %}
|
||||
<tr style="background:var(--accent-light);font-weight:500;">
|
||||
<td>{{ next_date }}</td>
|
||||
<td>{{ next_weekday }}</td>
|
||||
<td class="na">—</td>
|
||||
<td class="na">—</td>
|
||||
<td class="na">—</td>
|
||||
<td class="na">—</td>
|
||||
<td class="na">—</td>
|
||||
<td><span class="amp-cell" style="color:var(--accent);font-weight:700;" data-next="1">{{ next_amp }}</span></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% for row in rows %}
|
||||
<tr data-index="{{ row.global_idx }}" data-diff="{{ row.diff }}" data-date="{{ row.date }}" data-weekday="{{ row.weekday }}">
|
||||
<td>{{ row.date }}</td>
|
||||
@@ -150,10 +147,12 @@ function showDrawer(cell, product, calcRows, isNext) {
|
||||
document.getElementById('overlay').classList.add('show');
|
||||
document.getElementById('drawer').classList.add('show');
|
||||
|
||||
var row = cell.parentElement.parentElement;
|
||||
if (activeRow) activeRow.classList.remove('active');
|
||||
row.classList.add('active');
|
||||
activeRow = row;
|
||||
if (!isNext) {
|
||||
var row = cell.parentElement.parentElement;
|
||||
if (activeRow) activeRow.classList.remove('active');
|
||||
row.classList.add('active');
|
||||
activeRow = row;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user