处理自动刷新时间
This commit is contained in:
parent
ac2509958f
commit
f53e0e3846
|
|
@ -1885,7 +1885,7 @@ createApp({
|
||||||
loadPositions(), loadInstructions(), loadLedger(), loadProposals(),
|
loadPositions(), loadInstructions(), loadLedger(), loadProposals(),
|
||||||
loadDispatchMode(), loadWs(), loadStrategies(), loadOpLog(), loadOpenScan(), loadUpstream()]);
|
loadDispatchMode(), loadWs(), loadStrategies(), loadOpLog(), loadOpenScan(), loadUpstream()]);
|
||||||
await loadNames();
|
await loadNames();
|
||||||
lastRefresh.value = (health.value.now || '').slice(11, 19);
|
lastRefresh.value = new Date().toTimeString().slice(0, 8);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
wsPollSync();
|
wsPollSync();
|
||||||
}
|
}
|
||||||
|
|
@ -2080,20 +2080,20 @@ createApp({
|
||||||
}
|
}
|
||||||
|
|
||||||
// —— 自动刷新: 盘中 30s、休市 5min; 只拉快变数据, 不动 params(免得冲掉设置里在改的输入) ——
|
// —— 自动刷新: 盘中 30s、休市 5min; 只拉快变数据, 不动 params(免得冲掉设置里在改的输入) ——
|
||||||
let refreshTimer = null, refreshTick = 0;
|
let refreshTimer = null;
|
||||||
async function refreshLive() {
|
async function refreshLive() {
|
||||||
await Promise.all([loadOverview(), loadPositions(), loadInstructions(), loadLedger(),
|
// allSettled: 单个 loader 失败/超时(axios 60s 兜底)不拖累其余与时间戳更新。
|
||||||
|
await Promise.allSettled([loadOverview(), loadPositions(), loadInstructions(), loadLedger(),
|
||||||
loadProposals(), loadStrategies(), loadOpLog(), loadOpenScan(), loadUpstream()]);
|
loadProposals(), loadStrategies(), loadOpLog(), loadOpenScan(), loadUpstream()]);
|
||||||
await loadNames();
|
try { await loadNames(); } catch (e) {}
|
||||||
lastRefresh.value = (health.value.now || '').slice(11, 19);
|
// 用客户端钟, 保证"自动·HH:MM:SS"稳定跳动, 不依赖 /health 的 now。
|
||||||
|
lastRefresh.value = new Date().toTimeString().slice(0, 8);
|
||||||
}
|
}
|
||||||
function startAutoRefresh() {
|
function startAutoRefresh() {
|
||||||
if (refreshTimer) return;
|
if (refreshTimer) return;
|
||||||
refreshTimer = setInterval(() => {
|
// 固定 30s 自动刷新(开关开时)。不再按 marketOpen 分档 —— 交易日历对模拟/未来日期可能
|
||||||
if (!autoRefresh.value) return;
|
// 误判成非交易日, 那样会把刷新降到 5 分钟、体感像"卡住不刷"。休市时多刷几次也无害。
|
||||||
refreshTick++;
|
refreshTimer = setInterval(() => { if (autoRefresh.value) refreshLive(); }, 30000);
|
||||||
if (marketOpen.value || refreshTick % 10 === 0) refreshLive();
|
|
||||||
}, 30000);
|
|
||||||
}
|
}
|
||||||
onUnmounted(() => { if (refreshTimer) clearInterval(refreshTimer); });
|
onUnmounted(() => { if (refreshTimer) clearInterval(refreshTimer); });
|
||||||
onMounted(() => { loadAll(); loadPlan(); startAutoRefresh(); }); // 首屏 + 启动自动刷新
|
onMounted(() => { loadAll(); loadPlan(); startAutoRefresh(); }); // 首屏 + 启动自动刷新
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue