转换时间为UTC+8时间

This commit is contained in:
JIANG
2025-11-18 15:17:28 +08:00
parent 35c2c3bb86
commit 6748a8cee8

View File

@@ -372,7 +372,7 @@ const Timeline: React.FC<TimelineProps> = ({
type: "error", type: "error",
message: "请至少设定并应用一个图层的样式。", message: "请至少设定并应用一个图层的样式。",
}); });
// return; return;
} }
fetchFrameData( fetchFrameData(
currentTimeToDate(selectedDate, currentTime), currentTimeToDate(selectedDate, currentTime),
@@ -425,13 +425,14 @@ const Timeline: React.FC<TimelineProps> = ({
}; };
} }
}, [map, handlePause]); }, [map, handlePause]);
// 清除当天当前时间点后的缓存并重新获取数据
const clearCacheAndRefetch = (date: Date, timeInMinutes: number) => { const clearCacheAndRefetch = (date: Date, timeInMinutes: number) => {
const dateStr = date.toISOString().split("T")[0]; const dateStr = date.toISOString().split("T")[0];
const clearCache = ( const clearCache = (
cacheRef: React.MutableRefObject<Map<string, any[]>> cacheRef: ReturnType<typeof useRef<Map<string, any[]>>>
) => { ) => {
if (!cacheRef.current) return;
const cacheKeys = Array.from(cacheRef.current.keys()); const cacheKeys = Array.from(cacheRef.current.keys());
cacheKeys.forEach((key) => { cacheKeys.forEach((key) => {
const keyParts = key.split("_"); const keyParts = key.split("_");
@@ -440,9 +441,10 @@ const Timeline: React.FC<TimelineProps> = ({
if (cacheDate === dateStr && cacheTimeStr) { if (cacheDate === dateStr && cacheTimeStr) {
const [hours, minutes] = cacheTimeStr.split(":"); 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); cacheRef.current.delete(key);
} }
} }
@@ -451,7 +453,6 @@ const Timeline: React.FC<TimelineProps> = ({
clearCache(nodeCacheRef); clearCache(nodeCacheRef);
clearCache(linkCacheRef); clearCache(linkCacheRef);
// 重新获取当前时刻的新数据 // 重新获取当前时刻的新数据
fetchFrameData( fetchFrameData(
currentTimeToDate(selectedDate, currentTime), currentTimeToDate(selectedDate, currentTime),
@@ -502,13 +503,12 @@ const Timeline: React.FC<TimelineProps> = ({
); );
if (response.ok) { if (response.ok) {
// 清空当天当前时刻及之后的缓存并重新获取数据
clearCacheAndRefetch(calculationDate, calculationTime);
open?.({ open?.({
type: "success", type: "success",
message: "重新计算成功", message: "重新计算成功",
}); });
// 清空当天当前时刻及之后的缓存并重新获取数据
clearCacheAndRefetch(calculationDate, calculationTime);
} else { } else {
open?.({ open?.({
type: "error", type: "error",