Remove dashboard prewarm requests

This commit is contained in:
2569718930@qq.com
2026-04-15 15:51:08 +08:00
parent aa6ed30987
commit c55b83a134
3 changed files with 7 additions and 214 deletions
@@ -6,7 +6,6 @@ import {
DashboardStoreProvider,
useDashboardStore,
} from "@/hooks/useDashboardStore";
import { preloadChartJs } from "@/hooks/useChart";
import { I18nProvider, useI18n } from "@/hooks/useI18n";
import { CitySidebar } from "@/components/dashboard/CitySidebar";
import { DetailPanel } from "@/components/dashboard/DetailPanel";
@@ -82,42 +81,6 @@ function DashboardScreen() {
};
}, [store]);
useEffect(() => {
const browserWindow = window as Window & {
requestIdleCallback?: (
cb: IdleRequestCallback,
options?: IdleRequestOptions,
) => number;
cancelIdleCallback?: (handle: number) => void;
};
if (typeof browserWindow.requestIdleCallback === "function") {
const handle = browserWindow.requestIdleCallback(() => {
void loadHistoryModal();
void loadFutureForecastModal();
}, { timeout: 1200 });
return () => {
if (typeof browserWindow.cancelIdleCallback === "function") {
browserWindow.cancelIdleCallback(handle);
}
};
}
const timeoutId = window.setTimeout(() => {
void loadHistoryModal();
void loadFutureForecastModal();
}, 500);
return () => {
window.clearTimeout(timeoutId);
};
}, []);
useEffect(() => {
if (!store.selectedCity) return;
void preloadChartJs();
void loadHistoryModal();
void loadFutureForecastModal();
}, [store.selectedCity]);
// Avoid full-page flashing on initial load; only show this overlay for manual refresh.
const showLoading =
store.loadingState.cities ||