From a57caa72a54efe9de3fe26a6c36d3e8038267377 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 17 七月 2025 09:09:49 +0800
Subject: [PATCH] 修改x按钮

---
 src/components/menu/TimeLine.vue |   88 ++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue
index b92ddbe..6951358 100644
--- a/src/components/menu/TimeLine.vue
+++ b/src/components/menu/TimeLine.vue
@@ -153,7 +153,9 @@
 import { useSimStore } from "@/store/simulation";
 import { storeToRefs } from "pinia";
 const simStore = useSimStore();
-const { selectedScheme, frameNum, layerDate } = storeToRefs(simStore);
+const { selectedScheme, frameNum, layerDate, schemWaterInfo } =
+  storeToRefs(simStore);
+import { clearAllPoints } from "@/utils/map";
 
 const emit = defineEmits([
   "timeUpdate",
@@ -319,7 +321,8 @@
 
   // 鏂板缓鏂规涓殑瀹炴椂妯℃嫙涓嶈兘鍊嶉��
   if (selectedScheme.value.type === 2 && simStore.rePlayList.length == 0) {
-    // 绫诲瀷涓� 2锛氭瘡 5 绉掕烦鍔ㄤ竴娆�
+    console.log("鏂板缓鏂规瀹炴椂妯℃嫙浜旂涓�璺�");
+    // 瀹炴椂妯℃嫙锛氭瘡 5 绉掕烦鍔ㄤ竴娆�
     playInterval = setInterval(() => {
       const fiveSeconds = 5;
       const totalDuration = duration.value; // 鎬绘椂闀匡紙绉掞級
@@ -337,8 +340,9 @@
       }
 
       // 瑙﹀彂杩涘害鏇存柊
-      const progress = currentTime.value / totalDuration;
-      emit("timeUpdate", progress * 100);
+      // const progress = currentTime.value / totalDuration;
+      // 瀹炴椂妯℃嫙搴旇涓嶇敤鏄剧ず寮圭獥鍚�
+      // emit("timeUpdate", progress * 100);
 
       // 濡傛灉闇�瑕佽Е鍙戞煇浜涙洿鏂板嚱鏁帮紝涔熷彲浠ヤ繚鐣�
       updateWaterColorByTime();
@@ -364,6 +368,7 @@
         currentTime.value = duration.value;
         stopPlayback();
         isPlaying.value = false;
+        finishPlay.value = true;
         emit("isPlaying", false);
         emit("playbackFinished", true);
         return;
@@ -379,7 +384,9 @@
       }
 
       const progress = currentTime.value / duration.value;
-      emit("timeUpdate", progress * 100);
+      if (selectedScheme.value.type !== 2) {
+        emit("timeUpdate", progress * 100);
+      }
     }, 1000 / playbackRate.value);
   }
 };
@@ -387,6 +394,7 @@
 // 闄嶉洦鏁版嵁鐩稿叧鍙橀噺
 let rainFallValues = ref([]); // 瀛樺偍鍘熷闄嶉洦閲忔暟鎹�
 let minRainValue = ref(Infinity);
+let averageRainIntensity = ref();
 let maxRainValue = ref(-Infinity);
 // 鑾峰彇闄嶉洦鏁版嵁
 function getRainfallData() {
@@ -467,6 +475,19 @@
 
   // 鎻愬彇 intensity 鍊�
   rainFallValues.value = hourlyRainfallList.map((r) => r.intensity);
+  // 璁$畻骞冲潎闆ㄥ己
+  if (rainFallValues.value.length > 0) {
+    const sumIntensity = rainFallValues.value.reduce(
+      (sum, val) => sum + val,
+      0
+    );
+    averageRainIntensity.value = sumIntensity / rainFallValues.value.length;
+  } else {
+    averageRainIntensity.value = 0; // 鎴栬�� null 琛ㄧず鏃犳暟鎹�
+  }
+
+  console.log("骞冲潎闆ㄥ己涓猴細", averageRainIntensity.value);
+
   minRainValue.value = Math.min(...rainFallValues.value);
   maxRainValue.value = Math.max(...rainFallValues.value);
 
@@ -731,9 +752,15 @@
   // 鎵撳嵃淇℃伅
   // console.log("========================================");
   // console.log(`銆愭椂闂存埑銆�: ${new Date(currentTimeMs).toLocaleString()}`);
-  console.log(`銆愮疮璁¢檷闆ㄩ噺 R銆�: ${currentTotal !== null ? currentTotal.toFixed(2) : '鏈煡'} mm`);
+  console.log(
+    `銆愮疮璁¢檷闆ㄩ噺 R銆�: ${
+      currentTotal !== null ? currentTotal.toFixed(2) : "鏈煡"
+    } mm`
+  );
   // console.log(`銆愬綋鍓嶉樁娈点��: 绗� ${currentStage} 闃舵`);
-  console.log(`銆愰鑹� HEX銆�: ${colorState.colorStages[currentStage]?.color || '鏈畾涔�'}`);
+  console.log(
+    `銆愰鑹� HEX銆�: ${colorState.colorStages[currentStage]?.color || "鏈畾涔�"}`
+  );
   // console.log(`銆愰�忔槑搴� Alpha銆�: ${colorState.colorStages[currentStage]?.alpha || '鏈畾涔�'}`);
   // console.log("========================================");
   // 搴旂敤棰滆壊
@@ -1000,7 +1027,12 @@
       watersMaxHeight,
       watersMinHeight
     );
-
+    const waterInfoArr = [
+      watersMaxHeight,
+      maxRainValue.value,
+      averageRainIntensity.value,
+    ];
+    schemWaterInfo.value = waterInfoArr;
     // 鏇存柊鏃堕棿杞寸浉鍏虫暟鎹�
     if (timestamps) {
       frameNum.value = timestamps.length;
@@ -1022,7 +1054,6 @@
     });
   }
 }
-
 // 鎾斁瀹屾垚鍚庣殑鍥炶皟
 function handlePlayFinished() {
   if (selectedScheme.value.type !== 2) return;
@@ -1030,8 +1061,6 @@
   currentReplayIndex.value++;
 
   if (currentReplayIndex.value < simStore.rePlayList.length) {
-    console.log(currentReplayIndex.value);
-
     // 鑷姩鎾斁涓嬩竴涓�
     initializeSimulationData(simStore.rePlayList[currentReplayIndex.value]);
     togglePlay();
@@ -1040,6 +1069,7 @@
     // 鎵�鏈夐」鐩挱鏀惧畬鎴�
     currentReplayIndex.value = 0; // 閲嶇疆绱㈠紩
     isPlaying.value = false; // 鍋滄鎾斁
+    emit("timeUpdate", 100); // 鍦ㄦ墍鏈夐」鐩挱鏀惧畬姣曞悗瑙﹀彂
   }
 }
 
@@ -1047,7 +1077,11 @@
 watch(
   () => finishPlay.value,
   (newVal) => {
-    if (newVal && selectedScheme.value.type === 2) {
+    if (
+      newVal &&
+      selectedScheme.value.type === 2 &&
+      simStore.rePlayList.length > 0
+    ) {
       handlePlayFinished();
     }
   }
@@ -1101,27 +1135,33 @@
   if (selectedScheme.value.type === 2) {
     try {
       await ElMessageBox.confirm("鏂规鏈仠姝㈡椂缁撴潫妯℃嫙鍚庯紝鍚庡彴灏嗗仠姝㈣绠�", {
-        confirmButtonText: "杩斿洖鍒楄〃",
-        cancelButtonText: "缁撴潫妯℃嫙",
+        confirmButtonText: "缁撴潫妯℃嫙",
+        cancelButtonText: "杩斿洖鍒楄〃",
         type: "warning",
       });
-      // 鐢ㄦ埛鐐瑰嚮浜嗙‘璁わ紝杩欓噷涓嶆墽琛屼换浣曟搷浣滐紝浠呭叧闂璇濇
+
+      const res = await stopSim(selectedScheme.value.id);
+      if (res.code == 404) {
+        ElMessage.warning("璇ユ湇鍔″凡鍋滄");
+      } else {
+        ElMessage.success("鏈嶅姟姝e湪鍋滄涓�");
+      }
     } catch (error) {
-      stopSim(selectedScheme.value.id).then((res) => {
-        if (res.code == 404) {
-          ElMessage.warning("璇ユ湇鍔″凡鍋滄");
-        } else {
-          ElMessage.success("鏈嶅姟姝e湪鍋滄涓�");
-        }
-      });
-      // return;
+      // 鐢ㄦ埛鐐瑰嚮浜嗐�愯繑鍥炲垪琛ㄣ�戞垨鑰呭嚭鐜伴敊璇�
+      return;
     }
   }
-  // 涓嶇type鏄笉鏄�2锛屾渶缁堥兘鎵ц缁撴潫妯℃嫙鐨勬搷浣�
+
+  // 涓嶇 type 鏄笉鏄� 2锛屾渶缁堥兘鎵ц缁撴潫妯℃嫙鎿嶄綔
   endSimulation();
 }
 
 async function endSimulation() {
+  clearAllPoints();
+  simStore.openDia = true;
+  simStore.crossSection = [];
+  // 缁撴潫妯℃嫙涔嬪悗娓呴櫎layer鍒楄〃
+  simStore.rePlayList = [];
   EventBus.emit("close-time");
   endSimulate();
   isWaterPrimitiveCreated.value = false;

--
Gitblit v1.9.3