feat: implement scan terminal service with caching and add corresponding dashboard UI components

This commit is contained in:
2569718930@qq.com
2026-04-26 05:58:07 +08:00
parent 62dd1201db
commit 901b870240
3 changed files with 78 additions and 17 deletions
+4 -7
View File
@@ -841,9 +841,7 @@ export function DashboardStoreProvider({
return;
}
if (!cached) {
setLoadingState((current) => ({ ...current, cityDetail: true }));
}
setLoadingState((current) => ({ ...current, cityDetail: !cached }));
const detailPromise = ensureCityDetail(cityName, false, "panel");
void Promise.allSettled([summaryPromise, detailPromise])
.then(([, detail]) => {
@@ -854,20 +852,19 @@ export function DashboardStoreProvider({
})
.finally(() => {
if (selectedCityRef.current !== cityName) return;
if (!cached) {
setLoadingState((current) => ({ ...current, cityDetail: false }));
}
setLoadingState((current) => ({ ...current, cityDetail: false }));
});
};
const focusCity = async (cityName: string) => {
const cached = cityDetailsByName[cityName];
selectedCityRef.current = cityName;
setSelectedCity(cityName);
setIsPanelOpen(false);
setSelectedForecastDate(null);
setFutureModalDate(null);
setForecastModalMode(null);
setLoadingState((current) => ({ ...current, cityDetail: true }));
setLoadingState((current) => ({ ...current, cityDetail: !cached }));
void Promise.allSettled([
ensureCitySummary(cityName),
ensureCityDetail(cityName, false, "panel"),