| | |
| | | colorState.lastTime = currentTime.value; |
| | | // ====== 新增:在 updateWaterColor 前打印当前信息 ====== |
| | | // // 获取当前累计降雨量 |
| | | // let currentTotal = null; |
| | | // const baseTimestamp = new Date(rainTotalInfo.value[0].time).getTime(); |
| | | // const currentTimeMs = baseTimestamp + currentTime.value * 1000; |
| | | let currentTotal = null; |
| | | const baseTimestamp = new Date(rainTotalInfo.value[0].time).getTime(); |
| | | const currentTimeMs = baseTimestamp + currentTime.value * 1000; |
| | | |
| | | // // 找到最接近的降雨数据点 |
| | | // for (let i = rainTotalInfo.value.length - 1; i >= 0; i--) { |
| | | // const dataTimeMs = new Date(rainTotalInfo.value[i].time).getTime(); |
| | | // if (dataTimeMs <= currentTimeMs) { |
| | | // currentTotal = rainTotalInfo.value[i].total; |
| | | // break; |
| | | // } |
| | | // } |
| | | // 找到最接近的降雨数据点 |
| | | for (let i = rainTotalInfo.value.length - 1; i >= 0; i--) { |
| | | const dataTimeMs = new Date(rainTotalInfo.value[i].time).getTime(); |
| | | if (dataTimeMs <= currentTimeMs) { |
| | | currentTotal = rainTotalInfo.value[i].total; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // // 打印信息 |
| | | // 打印信息 |
| | | // console.log("========================================"); |
| | | // console.log(`【时间戳】: ${new Date(currentTimeMs).toLocaleString()}`); |
| | | // console.log(`【累计降雨量 R】: ${currentTotal !== null ? currentTotal.toFixed(2) : '未知'} mm`); |
| | | // console.log(`【当前阶段】: 第 ${currentStage} 阶段`); |
| | | console.log(`【时间戳】: ${new Date(currentTimeMs).toLocaleString()}`); |
| | | console.log(`【累计降雨量 R】: ${currentTotal !== null ? currentTotal.toFixed(2) : '未知'} mm`); |
| | | console.log(`【当前阶段】: 第 ${currentStage} 阶段`); |
| | | // console.log(`【颜色 HEX】: ${colorState.colorStages[currentStage]?.color || '未定义'}`); |
| | | // console.log(`【透明度 Alpha】: ${colorState.colorStages[currentStage]?.alpha || '未定义'}`); |
| | | // console.log("========================================"); |
| | |
| | | } |
| | | |
| | | // console.log('获取到的 serviceName:', serviceInfo); |
| | | |
| | | // 根据 layer.json 获取时间轴信息 |
| | | const { |
| | | waterTimestamps: timestamps, |
| | |
| | | "YYYY-MM-DD HH:mm:ss" |
| | | ); |
| | | } |
| | | |
| | | minFlowRate = watersMinHeight; |
| | | maxFlowRate = watersMaxHeight; |
| | | } catch (error) { |
| | |
| | | // 因为这个函数实时模拟监听也需要使用,所以封装了一个函数 |
| | | await initializeSimulationData(); |
| | | }); |
| | | |
| | | const shouldAutoPlay = ref(false); |
| | | |
| | | // 监听 layerDate 变化后标记准备播放 |
| | | watch( |
| | | () => layerDate.value, |
| | |
| | | }, |
| | | { deep: true } |
| | | ); |
| | | |
| | | // 等待 finishPlay 成功后再播放 |
| | | watchEffect(() => { |
| | | if (shouldAutoPlay.value && finishPlay.value && !isPlaying.value) { |
| | |
| | | shouldAutoPlay.value = false; |
| | | } |
| | | }); |
| | | |
| | | // 根据返回数据的个数去渲染时间轴 |
| | | function updateTimelineRange() { |
| | | if (waterTimestamps.value.length > 0) { |
| | |
| | | duration.value = (last - first) / 1000; // 毫秒转秒 |
| | | } |
| | | } |
| | | |
| | | onBeforeUnmount(() => { |
| | | stopPlayback(); |
| | | destoryWaterPrimitive(); |