市场监控 1 分钟强制刷新 11 城数据

This commit is contained in:
2569718930@qq.com
2026-05-14 01:13:53 +08:00
parent 6c4f43fba6
commit d2472fa0c2
@@ -44,22 +44,21 @@ export default function MonitorPanel() {
return localStorage.getItem("monitor_notify") !== "off"; return localStorage.getItem("monitor_notify") !== "off";
}); });
// Trigger loading for monitoring cities not yet in store // 1 min force-refresh all 11 monitoring cities
useEffect(() => { useEffect(() => {
const missing = MONITOR_KEYS.filter((k) => !details[k]);
if (missing.length === 0) return;
let cancelled = false; let cancelled = false;
async function load() { async function refreshAll() {
for (const k of missing) { for (const k of MONITOR_KEYS) {
if (cancelled) break; if (cancelled) break;
try { try {
await store.ensureCityDetail(k, false, "panel"); await store.ensureCityDetail(k, true, "panel");
} catch {} } catch {}
} }
} }
load(); refreshAll();
return () => { cancelled = true; }; const t = setInterval(refreshAll, 60_000);
}, [store.ensureCityDetail, Object.keys(details).length > 0]); return () => { cancelled = true; clearInterval(t); };
}, [store.ensureCityDetail]);
const cities: MonitorCity[] = useMemo(() => { const cities: MonitorCity[] = useMemo(() => {
return MONITOR_KEYS.map((k) => ({ key: k, detail: details[k] })); return MONITOR_KEYS.map((k) => ({ key: k, detail: details[k] }));