From 9aed93946a567c874c847b4d3e356058b0455ae7 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期二, 01 七月 2025 16:13:22 +0800
Subject: [PATCH] 2

---
 src/components/monifangzhen/echartInfo.vue |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/components/monifangzhen/echartInfo.vue b/src/components/monifangzhen/echartInfo.vue
index 3f73aaa..6def9dc 100644
--- a/src/components/monifangzhen/echartInfo.vue
+++ b/src/components/monifangzhen/echartInfo.vue
@@ -450,16 +450,33 @@
     }
   };
 
-  // 鎺у埗鏂规硶锛氱簿纭帶鍒跺姩鐢绘椂闂达紝鏈�鍚庝竴甯у湪绗� 90 绉�
+  let fixedFrameNum = null;
+  let startTime = null; // 灏唖tartTime绉诲埌澶栧眰
+  let elapsedBeforePause = 0; // 璁板綍鏆傚仠鍓嶅凡缁忚繃鍘荤殑鏃堕棿
+
   const startUpdating = () => {
-    if (updateInterval || dataIndex.value >= rainfallData.value.length) return;
+    if (updateInterval || dataIndex.value >= rainfallData.value.length) {
+      // console.log("Animation already running or completed");
+      return;
+    }
 
-    const totalDuration = simStore.frameNum * 1000; // 90绉�
+    // 濡傛灉鏄娆″惎鍔ㄦ垨閲嶆柊寮�濮�
+    if (fixedFrameNum === null) {
+      fixedFrameNum = simStore.frameNum;
+      elapsedBeforePause = 0;
+      startTime = Date.now();
+    } else {
+      // 濡傛灉鏄殏鍋滃悗缁х画锛岃皟鏁磗tartTime浠ュ弽鏄犲凡缁忚繃鍘荤殑鏃堕棿
+      startTime = Date.now() - elapsedBeforePause;
+    }
+
+    const totalDuration = fixedFrameNum * 1000;
     const totalPoints = rainfallData.value.length;
-    const startTime = Date.now();
 
-    const animate = (index = 0) => {
+
+    const animate = (index) => {
       if (index >= totalPoints) {
+        console.log("Animation completed");
         stopUpdating();
         return;
       }
@@ -469,7 +486,7 @@
       const delay = Math.max(0, startTime + expectedTime - now);
 
       updateInterval = setTimeout(() => {
-        dataIndex.value = index + 1; // 鍥犱负鏄粠 0 寮�濮� push 鐨�
+        dataIndex.value = index;
         updateData();
         animate(index + 1);
       }, delay);
@@ -478,13 +495,26 @@
     animate(dataIndex.value);
   };
 
+  // 鏆傚仠鍑芥暟闇�瑕佽褰曞凡缁忚繃鍘荤殑鏃堕棿
   const stopUpdating = () => {
-    clearTimeout(updateInterval);
-    updateInterval = null;
+    if (updateInterval) {
+      clearTimeout(updateInterval);
+      updateInterval = null;
+      // 璁板綍鏆傚仠鏃跺凡缁忚繃鍘荤殑鏃堕棿
+      elapsedBeforePause = Date.now() - startTime;
+    }
   };
+
+  // const stopUpdating = () => {
+  //   clearTimeout(updateInterval);
+  //   updateInterval = null;
+  // };
 
   const resetLoading = () => {
     stopUpdating();
+    fixedFrameNum = null;
+    startTime = null;
+    elapsedBeforePause = 0;
     dataIndex.value = 0;
     data1.value = [0];
     data2.value = [0];

--
Gitblit v1.9.3