更改 SCADA 设备列表条目关键词;样式设置中新增彩虹色带;强制计算后清除计算范围内的缓存;
This commit is contained in:
@@ -27,7 +27,6 @@ import { FiSkipBack, FiSkipForward } from "react-icons/fi";
|
||||
import { useData } from "../MapComponent";
|
||||
import { config, NETWORK_NAME } from "@/config/config";
|
||||
import { useMap } from "../MapComponent";
|
||||
import { Network } from "inspector/promises";
|
||||
const backendUrl = config.backendUrl;
|
||||
|
||||
interface TimelineProps {
|
||||
@@ -139,10 +138,6 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(
|
||||
// "Query Time:",
|
||||
// queryTime.toLocaleDateString() + " " + queryTime.toLocaleTimeString()
|
||||
// );
|
||||
// 等待所有有效请求
|
||||
const responses = await Promise.all(requests);
|
||||
|
||||
@@ -211,7 +206,6 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
|
||||
// 播放时间间隔选项
|
||||
const intervalOptions = [
|
||||
// { value: 1000, label: "1秒" },
|
||||
{ value: 2000, label: "2秒" },
|
||||
{ value: 5000, label: "5秒" },
|
||||
{ value: 10000, label: "10秒" },
|
||||
@@ -239,7 +233,7 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
}
|
||||
debounceRef.current = setTimeout(() => {
|
||||
setCurrentTime(value);
|
||||
}, 300); // 300ms 防抖延迟
|
||||
}, 500); // 500ms 防抖延迟
|
||||
},
|
||||
[timeRange, minTime, maxTime]
|
||||
);
|
||||
@@ -441,6 +435,11 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
// 提前提取日期和时间值,避免异步操作期间被时间轴拖动改变
|
||||
const calculationDate = selectedDate;
|
||||
const calculationTime = currentTime;
|
||||
const calculationDateStr = calculationDate.toISOString().split("T")[0];
|
||||
|
||||
setIsCalculating(true);
|
||||
// 显示处理中的通知
|
||||
open?.({
|
||||
@@ -451,8 +450,8 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
try {
|
||||
const body = {
|
||||
name: NETWORK_NAME,
|
||||
simulation_date: selectedDate.toISOString().split("T")[0], // YYYY-MM-DD
|
||||
start_time: `${formatTime(currentTime)}:00`, // HH:MM:00
|
||||
simulation_date: calculationDateStr, // YYYY-MM-DD
|
||||
start_time: `${formatTime(calculationTime)}:00`, // HH:MM:00
|
||||
duration: calculatedInterval,
|
||||
};
|
||||
|
||||
@@ -468,6 +467,44 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
// 清空当天当前时刻及之后的缓存
|
||||
const currentDateStr = calculationDateStr;
|
||||
const currentTimeInMinutes = calculationTime;
|
||||
|
||||
// 清空node缓存
|
||||
const nodeCacheKeys = Array.from(nodeCacheRef.current.keys());
|
||||
nodeCacheKeys.forEach((key) => {
|
||||
const keyParts = key.split("_");
|
||||
const cacheDate = keyParts[0].split("T")[0];
|
||||
const cacheTimeStr = keyParts[0].split("T")[1];
|
||||
|
||||
if (cacheDate === currentDateStr && cacheTimeStr) {
|
||||
const [hours, minutes] = cacheTimeStr.split(":");
|
||||
const cacheTimeInMinutes = parseInt(hours) * 60 + parseInt(minutes);
|
||||
|
||||
if (cacheTimeInMinutes >= currentTimeInMinutes) {
|
||||
nodeCacheRef.current.delete(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 清空link缓存
|
||||
const linkCacheKeys = Array.from(linkCacheRef.current.keys());
|
||||
linkCacheKeys.forEach((key) => {
|
||||
const keyParts = key.split("_");
|
||||
const cacheDate = keyParts[0].split("T")[0];
|
||||
const cacheTimeStr = keyParts[0].split("T")[1];
|
||||
|
||||
if (cacheDate === currentDateStr && cacheTimeStr) {
|
||||
const [hours, minutes] = cacheTimeStr.split(":");
|
||||
const cacheTimeInMinutes = parseInt(hours) * 60 + parseInt(minutes);
|
||||
|
||||
if (cacheTimeInMinutes >= currentTimeInMinutes) {
|
||||
linkCacheRef.current.delete(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
open?.({
|
||||
type: "success",
|
||||
message: "重新计算成功",
|
||||
|
||||
Reference in New Issue
Block a user