fix(timeline): prevent negative initial time

This commit is contained in:
2026-07-16 11:31:51 +08:00
parent f5e7312e3b
commit 041b4ef89d
4 changed files with 83 additions and 24 deletions
+5 -2
View File
@@ -32,6 +32,7 @@ import {
markMapResourcePersistent,
} from "./mapLifecycle";
import { createOperationalMapResources } from "./operationalLayers";
import { getRoundedCurrentTimelineMinutes } from "./Controls/timelineTime";
interface MapComponentProps {
children?: React.ReactNode;
@@ -155,7 +156,9 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
const [compareMap, setCompareMap] = useState<OlMap>();
const [compareDeckLayer, setCompareDeckLayer] = useState<DeckLayer>();
// currentCalData 用于存储当前计算结果
const [currentTime, setCurrentTime] = useState<number>(-1); // 默认选择当前时间
const [currentTime, setCurrentTime] = useState<number>(
getRoundedCurrentTimelineMinutes,
); // 默认选择当前时间
// const [selectedDate, setSelectedDate] = useState<Date>(new Date("2025-9-17"));
const [selectedDate, setSelectedDate] = useState<Date>(new Date()); // 默认今天
const [schemeName, setSchemeName] = useState<string>(""); // 当前方案名称
@@ -775,7 +778,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
}, [compareMap, isCompareMode, map]);
useEffect(() => {
setCurrentTime(-1);
setCurrentTime(getRoundedCurrentTimelineMinutes());
setSelectedDate(new Date());
setSchemeName("");
setCurrentJunctionCalData([]);