From 6748a8cee8df3ef53e23e394abbc9d24e7c27d8b Mon Sep 17 00:00:00 2001 From: JIANG Date: Tue, 18 Nov 2025 15:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=97=B6=E9=97=B4=E4=B8=BAUT?= =?UTF-8?q?C+8=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/OlMap/Controls/Timeline.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/OlMap/Controls/Timeline.tsx b/src/app/OlMap/Controls/Timeline.tsx index 1953e2f..4683aa5 100644 --- a/src/app/OlMap/Controls/Timeline.tsx +++ b/src/app/OlMap/Controls/Timeline.tsx @@ -372,7 +372,7 @@ const Timeline: React.FC = ({ type: "error", message: "请至少设定并应用一个图层的样式。", }); - // return; + return; } fetchFrameData( currentTimeToDate(selectedDate, currentTime), @@ -425,13 +425,14 @@ const Timeline: React.FC = ({ }; } }, [map, handlePause]); - + // 清除当天当前时间点后的缓存并重新获取数据 const clearCacheAndRefetch = (date: Date, timeInMinutes: number) => { const dateStr = date.toISOString().split("T")[0]; const clearCache = ( - cacheRef: React.MutableRefObject> + cacheRef: ReturnType>> ) => { + if (!cacheRef.current) return; const cacheKeys = Array.from(cacheRef.current.keys()); cacheKeys.forEach((key) => { const keyParts = key.split("_"); @@ -440,9 +441,10 @@ const Timeline: React.FC = ({ if (cacheDate === dateStr && cacheTimeStr) { const [hours, minutes] = cacheTimeStr.split(":"); - const cacheTimeInMinutes = parseInt(hours) * 60 + parseInt(minutes); + const cacheTimeInMinutes = + (parseInt(hours) + 8) * 60 + parseInt(minutes); - if (cacheTimeInMinutes >= timeInMinutes) { + if (cacheTimeInMinutes >= timeInMinutes && cacheRef.current) { cacheRef.current.delete(key); } } @@ -451,7 +453,6 @@ const Timeline: React.FC = ({ clearCache(nodeCacheRef); clearCache(linkCacheRef); - // 重新获取当前时刻的新数据 fetchFrameData( currentTimeToDate(selectedDate, currentTime), @@ -502,13 +503,12 @@ const Timeline: React.FC = ({ ); if (response.ok) { - // 清空当天当前时刻及之后的缓存并重新获取数据 - clearCacheAndRefetch(calculationDate, calculationTime); - open?.({ type: "success", message: "重新计算成功", }); + // 清空当天当前时刻及之后的缓存并重新获取数据 + clearCacheAndRefetch(calculationDate, calculationTime); } else { open?.({ type: "error",