From 68e0faf021b54ab38bba0b07c76c3d5f43dfc311 Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期二, 24 六月 2025 17:30:31 +0800 Subject: [PATCH] 11111111 --- src/components/menu/TimeLine.vue | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue index 5f6c297..e4ba363 100644 --- a/src/components/menu/TimeLine.vue +++ b/src/components/menu/TimeLine.vue @@ -149,6 +149,7 @@ const isColorRenderEnabled = ref(false); // 鍋囪杩欐槸浣犵殑棰滆壊娓叉煋寮�鍏崇姸鎬� const isWaterPrimitiveCreated = ref(false); let playInterval = null; +let timeStepInfo = null; let rainTotalInfo = ([]); const isRainEnabled = ref(false); const rainParams = reactive({ @@ -304,6 +305,9 @@ const rainfallList = data.rainfalls; console.log("鏈�缁堢殑 rainfallList:", rainfallList); rainTotalInfo.value = rainfallList + calculateTimeStep(rainTotalInfo.value) + // 浣跨敤绀轰緥 + timeStepInfo = calculateTimeStep(rainTotalInfo.value); // 鎻愬彇 intensity 鍊� rainFallValues.value = rainfallList.map((r) => r.intensity); @@ -373,12 +377,46 @@ } } // 榛樿鏃犻洦鐘舵�� - + return { name: "鏃犻洦", size: 0.3, speed: 10, density: 10, color: "#F0F8FF" }; } // 鏍规嵁鎾斁杩涘害鏇存柊澶╂皵鏁堟灉锛堝凡浼樺寲锛� let lastUsedIndex = -1; // 缂撳瓨涓婁竴娆′娇鐢ㄧ殑绱㈠紩锛岄槻姝㈤噸澶嶆洿鏂� let lastRainValue = null; + +function calculateTimeStep(dataArray) { + if (!dataArray || dataArray.length < 2) { + console.warn('鏁版嵁涓嶈冻锛屾棤娉曡绠楁椂闂存闀�'); + return null; + } + + // 瑙f瀽鏃堕棿瀛楃涓蹭负 Date 瀵硅薄 + function parseTime(timeStr) { + return new Date(timeStr.replace(' ', 'T')); // 鍏煎 ISO 鏍煎紡 + } + + const firstTime = parseTime(dataArray[0].time); + const secondTime = parseTime(dataArray[1].time); + + // 璁$畻鏃堕棿宸紙姣锛� + const diffMs = Math.abs(secondTime - firstTime); + + // 杞崲涓哄皬鏃舵暟锛堜繚鐣欏皬鏁帮級 + let timeStepHours = diffMs / (1000 * 60 * 60); // 姣 -> 灏忔椂 + + // 鍙�夛細閬嶅巻鎵�鏈夌浉閭婚」妫�鏌ユ槸鍚︿竴鑷� + for (let i = 1; i < dataArray.length - 1; i++) { + const current = parseTime(dataArray[i].time); + 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)} 灏忔椂`); + } + } + + return timeStepHours; +} + function updateWaterColorByTime() { if (!rainTotalInfo.value || rainTotalInfo.value.length === 0) return; const progress = currentTime.value / duration.value; @@ -392,21 +430,22 @@ const currentTotal = currentData.total; const nextTotal = nextData.total; const total = currentTotal + (nextTotal - currentTotal) * alpha; + console.log(`璁$畻寰楀埌鐨勬椂闂存闀夸负: ${timeStepInfo} 灏忔椂`); // 鏍规嵁 total 璁剧疆棰滆壊 let color = '#D4F2E7'; // 榛樿钃濊壊 if (total >= 150) { - color = '#663300'; // 榛� - 澶ч洦 + color = '#663300'; } else if (total >= 125) { - color = '#B26633'; // 榛勭豢 - 涓洦 + color = '#B26633'; } else if (total >= 100) { - color = '#CC9966'; // 缁� - 涓洦 + color = '#CC9966'; } else if (total >= 75) { - color = '#CCE5FF'; // 闈掔豢 - 灏忛洦 + color = '#CCE5FF'; } else if (total >= 50) { - color = '#99CCFF'; // 澶╄摑 - 灏忛洦 + color = '#99CCFF'; } else if (total >= 25) { - color = '#66B3FF'; // 娴呰摑 - 寰噺 + color = '#66B3FF'; } // console.log(`褰撳墠 total: ${total.toFixed(2)}, 棰滆壊: ${color}`); // updateWaterColor(color) -- Gitblit v1.9.3