guonan
2025-06-25 2f387619c1cf834c058ac77a3fd4cabc42e5d4de
src/components/menu/TimeLine.vue
@@ -152,7 +152,7 @@
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
const simStore = useSimStore();
const { selectedScheme, frameNum } = storeToRefs(simStore);
const { selectedScheme, frameNum, layerDate } = storeToRefs(simStore);
const emit = defineEmits([
  "timeUpdate",
@@ -191,7 +191,7 @@
const isWaterPrimitiveCreated = ref(false);
let playInterval = null;
let timeStepInfo = null;
let rainTotalInfo = ([]);
let rainTotalInfo = [];
const isRainEnabled = ref(false);
const rainParams = reactive({
  rainSize: 0.5,
@@ -349,10 +349,10 @@
  const rainfallList = data.rainfalls;
  console.log("最终的 rainfallList:", rainfallList);
  rainTotalInfo.value = rainfallList
  calculateTimeStep(rainTotalInfo.value)
  rainTotalInfo.value = rainfallList;
  calculateTimeStep(rainTotalInfo.value);
  // 使用示例
 timeStepInfo = calculateTimeStep(rainTotalInfo.value);
  timeStepInfo = calculateTimeStep(rainTotalInfo.value);
  // 提取 intensity 值
  rainFallValues.value = rainfallList.map((r) => r.intensity);
@@ -431,13 +431,13 @@
function calculateTimeStep(dataArray) {
  if (!dataArray || dataArray.length < 2) {
    console.warn('数据不足,无法计算时间步长');
    console.warn("数据不足,无法计算时间步长");
    return null;
  }
  // 解析时间字符串为 Date 对象
  function parseTime(timeStr) {
    return new Date(timeStr.replace(' ', 'T')); // 兼容 ISO 格式
    return new Date(timeStr.replace(" ", "T")); // 兼容 ISO 格式
  }
  const firstTime = parseTime(dataArray[0].time);
@@ -455,7 +455,9 @@
    const next = parseTime(dataArray[i + 1].time);
    const step = Math.abs(next - current) / (1000 * 60 * 60); // 毫秒 -> 小时
    if (Math.abs(step - timeStepHours) > 0.01) {
      console.warn(`在索引 ${i} 处发现了不同的时间步长: ${step.toFixed(2)} 小时`);
      console.warn(
        `在索引 ${i} 处发现了不同的时间步长: ${step.toFixed(2)} 小时`
      );
    }
  }
@@ -481,7 +483,9 @@
  const currentTimestamp = timeToTimestamp(currentData.time);
  // 已过去的时间(小时)
  const elapsedTimeInHours = parseFloat((currentTimestamp - initialTimestamp) / (1000 * 60 * 60));
  const elapsedTimeInHours = parseFloat(
    (currentTimestamp - initialTimestamp) / (1000 * 60 * 60)
  );
  console.log(`持续了 ${elapsedTimeInHours} 小时`);
@@ -516,13 +520,13 @@
  // 输出关键信息
  console.table({
    '当前时间': currentData.time,
    '累计时长 D(t) (h)': D.toFixed(2),
    '雨强阈值 IR(t) (mm/h)': IR.toFixed(2),
    '当前降雨强度 I(t) (mm/h)': intensity.toFixed(2),
    '当前阶段编号': stage,
    '最大阶段编号': maxStage,
    '是否触发泥石流': stage >= 5 ? '是' : '否'
    当前时间: currentData.time,
    "累计时长 D(t) (h)": D.toFixed(2),
    "雨强阈值 IR(t) (mm/h)": IR.toFixed(2),
    "当前降雨强度 I(t) (mm/h)": intensity.toFixed(2),
    当前阶段编号: stage,
    最大阶段编号: maxStage,
    是否触发泥石流: stage >= 5 ? "是" : "否",
  });
  // 根据最大阶段设置颜色
@@ -757,12 +761,16 @@
  try {
    // 当前方案的所有信息
    const schemeInfo = selectedScheme.value;
    const jsonFetch = ref(null);
    serviceInfo = schemeInfo.serviceName;
    if (selectedScheme.value.type == 2) {
      speedShow.value = false;
      jsonFetch.value = layerDate.value;
      // serviceInfo = layerDate.value;
    } else {
      getRainfallData();
      speedShow.value = true;
      jsonFetch.value = null;
    }
    // console.log('获取到的 serviceName:', serviceInfo);
@@ -772,7 +780,7 @@
      waterTimestamps: timestamps,
      watersMaxHeight,
      watersMinHeight,
    } = await fetchWaterSimulationData(serviceInfo);
    } = await fetchWaterSimulationData(serviceInfo, jsonFetch.value);
    console.log(
      "当前方案下的最大水位深度和最小水位深度",
      watersMaxHeight,