MonitorPanel 自动触发未加载城市的 ensureCityDetail

This commit is contained in:
2569718930@qq.com
2026-05-14 00:52:14 +08:00
parent c006d13fea
commit 79944432fb
@@ -44,6 +44,23 @@ export default function MonitorPanel() {
return localStorage.getItem("monitor_notify") !== "off";
});
// Trigger loading for monitoring cities not yet in store
useEffect(() => {
const missing = MONITOR_KEYS.filter((k) => !details[k]);
if (missing.length === 0) return;
let cancelled = false;
async function load() {
for (const k of missing) {
if (cancelled) break;
try {
await store.ensureCityDetail(k, false, "panel");
} catch {}
}
}
load();
return () => { cancelled = true; };
}, [store.ensureCityDetail, Object.keys(details).length > 0]);
const cities: MonitorCity[] = useMemo(() => {
return MONITOR_KEYS.map((k) => ({ key: k, detail: details[k] }));
}, [details]);