From 043c56f2e3a3507bdc439b7df7c116ce2eeea173 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期五, 23 五月 2025 16:54:16 +0800
Subject: [PATCH] 修改跳转

---
 src/components/menu/TimeLine.vue |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue
index eaabc45..0ac6d4e 100644
--- a/src/components/menu/TimeLine.vue
+++ b/src/components/menu/TimeLine.vue
@@ -31,7 +31,7 @@
         <div>涓撻娓叉煋:
           <el-switch v-model="isColorRenderEnabled" @change="handleColorRenderChange" style="margin-top:-3px"
             :disabled="!isPlaying || !isWaterPrimitiveCreated" />
-            <!-- active-text="寮�" inactive-text="鍏�" -->
+          <!-- active-text="寮�" inactive-text="鍏�" -->
         </div>
       </div>
       <div class="timeline-track" ref="timelineTrack" @click="seekToPosition">
@@ -295,7 +295,7 @@
     size: 0.7,
     speed: 40,
     density: 35,
-    color: '#ADD8E6' 
+    color: '#ADD8E6'
   },
   {
     name: '澶ч洦',
@@ -313,7 +313,7 @@
     size: 1.3,
     speed: 90,
     density: 80,
-    color: '#ADD8E6' 
+    color: '#ADD8E6'
   },
   {
     name: '澶ф毚闆�',
@@ -385,12 +385,31 @@
   clearInterval(playInterval);
 };
 
-const skipForward = () =>
-  (currentTime.value = Math.min(currentTime.value + 1, duration.value)); // 鍚戝墠璺宠浆1绉�
+const skipForward = () => {
+  if (waterTimestamps.value.length === 0) return;
+  const currentIndex = findClosestTimestampIndex(currentTime.value);
+  const nextIndex = currentIndex + 1;
+  if (nextIndex >= waterTimestamps.value.length) {
+    return;
+  }
+  const baseTimestamp = waterTimestamps.value[0];
+  currentTime.value = (waterTimestamps.value[nextIndex] - baseTimestamp) / 1000;
+  setTimeForWaterSimulation(nextIndex);
+  if (!isPlaying.value) pauseWaterSimulation();
+};
 
-const skipBackward = () =>
-  (currentTime.value = Math.max(currentTime.value - 1, 0)); // 鍚戝悗璺宠浆1绉�
-
+const skipBackward = () => {
+  if (waterTimestamps.value.length === 0) return;
+  const currentIndex = findClosestTimestampIndex(currentTime.value);
+  const prevIndex = currentIndex - 1;
+  if (prevIndex < 0) {
+    return;
+  }
+  const baseTimestamp = waterTimestamps.value[0];
+  currentTime.value = (waterTimestamps.value[prevIndex] - baseTimestamp) / 1000;
+  setTimeForWaterSimulation(prevIndex);
+  if (!isPlaying.value) pauseWaterSimulation();
+};
 const toggleSpeedMenu = () => (showSpeedMenu.value = !showSpeedMenu.value);
 
 // 璁剧疆鎾斁閫熺巼
@@ -536,7 +555,7 @@
     });
   }
 });
-
+// 鏍规嵁杩斿洖鏁版嵁鐨勪釜鏁板幓娓叉煋鏃堕棿杞�
 function updateTimelineRange() {
   if (waterTimestamps.value.length > 0) {
     const [first, last] = [

--
Gitblit v1.9.3