From 510afa04d2d251ca75bf24e5ef08579c5793c4eb Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Wed, 22 Jul 2026 15:48:08 +0800
Subject: [PATCH] feat:历史轨迹增加自由播放点击功能
---
applications/drone-command/src/views/recordManage/historyTracks/TrajectoryDiaLog.vue | 67 +++++++++++++++++++++++++++++++--
1 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/applications/drone-command/src/views/recordManage/historyTracks/TrajectoryDiaLog.vue b/applications/drone-command/src/views/recordManage/historyTracks/TrajectoryDiaLog.vue
index 1ea0cbe..d682c78 100644
--- a/applications/drone-command/src/views/recordManage/historyTracks/TrajectoryDiaLog.vue
+++ b/applications/drone-command/src/views/recordManage/historyTracks/TrajectoryDiaLog.vue
@@ -52,7 +52,13 @@
<div class="val">{{ formData.stayDuration }}</div>
</el-col>
</el-row>
- <div class="detail-title">轨迹点</div>
+ <div class="detail-title" style="display: flex; align-items: center">
+ 轨迹点
+ <el-icon class="track-play-btn" :size="26" @click.stop="handlePlayClick">
+ <VideoPause v-if="isPlaying" />
+ <VideoPlay v-else />
+ </el-icon>
+ </div>
<div class="command-table-container">
<div class="command-table-content">
<el-table ref="pointTableRef" class="command-table" :data="list" :row-class-name="getRowClassName">
@@ -66,7 +72,9 @@
</div>
</div>
<div class="footer">
- <el-button v-if="dialogMode != 'view'" color="#2B2B4C" @click="handleCancel">{{ dialogReadonly ? '关闭' : '取消' }}</el-button>
+ <el-button v-if="dialogMode != 'view'" color="#2B2B4C" @click="handleCancel">
+ {{ dialogReadonly ? '关闭' : '取消' }}
+ </el-button>
</div>
</div>
</div>
@@ -74,9 +82,9 @@
</template>
<script setup>
-import { Close } from '@element-plus/icons-vue'
+import { Close, VideoPause, VideoPlay } from '@element-plus/icons-vue'
-import { computed, nextTick, ref } from 'vue'
+import { computed, nextTick, onBeforeUnmount, ref } from 'vue'
import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue'
import { fwDroneFlightRecordDetailApi } from '@/views/recordManage/historyTracks/fwDroneFlightRecord'
import { fwDroneFlightRecordDetailPageApi } from '@/views/recordManage/historyTracks/flyTrajectory'
@@ -165,6 +173,7 @@
// 关闭后重置
function handleClosed() {
+ stopTrackPlay()
formData.value = initForm()
list.value = []
selectedPointIndex.value = 0
@@ -177,6 +186,43 @@
// 当前选中的轨迹点索引(与地图时间轴联动)
const selectedPointIndex = ref(0)
const pointTableRef = ref(null)
+const isPlaying = ref(false)
+const PLAY_INTERVAL = 1000
+let playTimer = null
+let playIndex = 0
+
+// 停止轨迹播放
+function stopTrackPlay() {
+ if (playTimer) {
+ clearInterval(playTimer)
+ playTimer = null
+ }
+ isPlaying.value = false
+}
+
+// 播放下一个轨迹点
+function playNextPoint() {
+ if (!list.value.length) {
+ stopTrackPlay()
+ return
+ }
+ if (playIndex >= list.value.length) playIndex = 0
+ mapRef.value?.clickWeekTime?.(list.value[playIndex], playIndex)
+ playIndex += 1
+}
+
+// 切换轨迹播放状态
+function handlePlayClick() {
+ if (isPlaying.value) {
+ stopTrackPlay()
+ return
+ }
+ if (!list.value.length) return
+ playIndex = selectedPointIndex.value || 0
+ isPlaying.value = true
+ playNextPoint()
+ playTimer = setInterval(playNextPoint, PLAY_INTERVAL)
+}
// 地图上点击轨迹点后,同步高亮表格对应行,并滚动到该行
function handlePointChange({ index } = {}) {
@@ -211,6 +257,7 @@
// 打开弹框
async function open({ mode, row } = {}) {
+ stopTrackPlay()
dialogMode.value = mode || 'add'
visible.value = true
await nextTick()
@@ -224,11 +271,16 @@
}
defineExpose({ open })
+
+// 卸载时清理播放定时器
+onBeforeUnmount(() => {
+ stopTrackPlay()
+})
</script>
<style scoped lang="scss">
:deep(.alarm-row) {
- background: #2B2B4C !important;
+ background: #2b2b4c !important;
td {
background-color: transparent !important;
@@ -244,4 +296,9 @@
color: #4faaff !important;
}
}
+
+.track-play-btn {
+ margin-left: 6px;
+ cursor: pointer;
+}
</style>
--
Gitblit v1.9.3