转换时间为UTC+8时间
This commit is contained in:
@@ -372,7 +372,7 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
type: "error",
|
||||
message: "请至少设定并应用一个图层的样式。",
|
||||
});
|
||||
// return;
|
||||
return;
|
||||
}
|
||||
fetchFrameData(
|
||||
currentTimeToDate(selectedDate, currentTime),
|
||||
@@ -425,13 +425,14 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
};
|
||||
}
|
||||
}, [map, handlePause]);
|
||||
|
||||
// 清除当天当前时间点后的缓存并重新获取数据
|
||||
const clearCacheAndRefetch = (date: Date, timeInMinutes: number) => {
|
||||
const dateStr = date.toISOString().split("T")[0];
|
||||
|
||||
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());
|
||||
cacheKeys.forEach((key) => {
|
||||
const keyParts = key.split("_");
|
||||
@@ -440,9 +441,10 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
|
||||
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<TimelineProps> = ({
|
||||
|
||||
clearCache(nodeCacheRef);
|
||||
clearCache(linkCacheRef);
|
||||
|
||||
// 重新获取当前时刻的新数据
|
||||
fetchFrameData(
|
||||
currentTimeToDate(selectedDate, currentTime),
|
||||
@@ -502,13 +503,12 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
// 清空当天当前时刻及之后的缓存并重新获取数据
|
||||
clearCacheAndRefetch(calculationDate, calculationTime);
|
||||
|
||||
open?.({
|
||||
type: "success",
|
||||
message: "重新计算成功",
|
||||
});
|
||||
// 清空当天当前时刻及之后的缓存并重新获取数据
|
||||
clearCacheAndRefetch(calculationDate, calculationTime);
|
||||
} else {
|
||||
open?.({
|
||||
type: "error",
|
||||
|
||||
Reference in New Issue
Block a user