From bb032a81c27fd9d603df5381e91c83e402604838 Mon Sep 17 00:00:00 2001 From: oldHome Date: Sat, 28 Jun 2025 16:48:48 +0800 Subject: [PATCH] =?UTF-8?q?fix=201=E8=A7=A3=E5=86=B3=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9B=A0=E4=B8=BAmenu=E7=BC=A9=E8=BF=9B?= =?UTF-8?q?=E6=8C=89=E9=92=AE=20=E9=80=A0=E6=88=90=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=E9=97=AE=E9=A2=98=20=E5=8C=85=E6=8B=AC=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=BD=BF=E7=94=A8=E5=9C=B0=E5=9B=BE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E5=9D=97=202=E6=89=93=E5=8D=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=89=8D=20=E5=B8=A6=E4=B8=8A=E9=A3=9E=E6=9C=BA?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E5=89=8D=E7=BC=80=203=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E6=8C=87=E7=82=B9=E9=A3=9E=E8=A1=8C=20=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=9C=80=E7=9F=AE=E9=A3=9E=E6=9C=BA=E7=9B=AE=E6=A0=87=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E6=98=AF=E4=B8=8D=E6=98=AF=E5=B0=8F=E4=BA=8E0=20?= =?UTF-8?q?=E5=8D=B3=E5=9C=B0=E9=9D=A2=E4=BB=A5=E4=B8=8B=20=E6=89=93?= =?UTF-8?q?=E6=96=AD=20=E4=B8=8D=E5=8F=91=E9=80=81mqtt=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/components/main/home/index.vue | 17 +++++++++--- .../layout/components/main/nofly/setNofly.vue | 18 ++++++++++--- .../components/main/nofly/setRestrictfly.vue | 18 ++++++++++--- .../layout/components/main/planes/index.vue | 11 +++++--- .../layout/components/main/planes/swarm.vue | 26 ++++++++++++++++--- .../layout/components/main/route/add.vue | 21 +++++++++++++++ src/views/layout/index.vue | 2 +- 7 files changed, 93 insertions(+), 20 deletions(-) diff --git a/src/views/layout/components/main/home/index.vue b/src/views/layout/components/main/home/index.vue index 5ef6c02..c321d91 100644 --- a/src/views/layout/components/main/home/index.vue +++ b/src/views/layout/components/main/home/index.vue @@ -108,7 +108,7 @@ export default { // 实时更新所有飞机位置 和轨迹 planePositions: { handler (allPositions) { - // allPositions 是一个数组,每个元素是该飞机的 position 数组 + // allPositions 是一个数组,每个元素是该飞机的 position 数组 allPositions.forEach((positions, idx) => { const n = positions.length if (n > 2) { @@ -130,10 +130,19 @@ export default { deep: true }, /** - * @description: 侧边栏显隐 + * @description: 侧边栏缩进有变化时 地图重新自适应 */ - isCollapse () { - return this.$store.state.app.isCollapse + isCollapse: { + handler (val) { + if (val) { + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) + } + }, + deep: true } }, destroyed () { diff --git a/src/views/layout/components/main/nofly/setNofly.vue b/src/views/layout/components/main/nofly/setNofly.vue index 60ffc95..48db50c 100644 --- a/src/views/layout/components/main/nofly/setNofly.vue +++ b/src/views/layout/components/main/nofly/setNofly.vue @@ -43,10 +43,20 @@ export default { }) } }, - isCollapse (val) { - if (val) { - this.$refs.mapbox.handleResize() - } + /** + * @description: 侧边栏缩进有变化时 地图重新自适应 + */ + isCollapse: { + handler (val) { + if (val) { + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) + } + }, + deep: true } } } diff --git a/src/views/layout/components/main/nofly/setRestrictfly.vue b/src/views/layout/components/main/nofly/setRestrictfly.vue index 1e62f08..d0e0644 100644 --- a/src/views/layout/components/main/nofly/setRestrictfly.vue +++ b/src/views/layout/components/main/nofly/setRestrictfly.vue @@ -43,10 +43,20 @@ export default { }) } }, - isCollapse (val) { - if (val) { - this.$refs.mapbox.handleResize() - } + /** + * @description: 侧边栏缩进有变化时 地图重新自适应 + */ + isCollapse: { + handler (val) { + if (val) { + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) + } + }, + deep: true } } } diff --git a/src/views/layout/components/main/planes/index.vue b/src/views/layout/components/main/planes/index.vue index d94a392..de3ac3b 100644 --- a/src/views/layout/components/main/planes/index.vue +++ b/src/views/layout/components/main/planes/index.vue @@ -290,11 +290,14 @@ export default { isCollapse: { handler (val) { if (val) { - this.$nextTick(() => { - this.$refs.mapbox.handleResize() - }) + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) } - } + }, + deep: true } } } diff --git a/src/views/layout/components/main/planes/swarm.vue b/src/views/layout/components/main/planes/swarm.vue index 6c8c4d6..db13648 100644 --- a/src/views/layout/components/main/planes/swarm.vue +++ b/src/views/layout/components/main/planes/swarm.vue @@ -202,6 +202,7 @@ export default { return } + let minTargetAlt = Infinity // 标记最矮飞机 的目标高度 初始化为正无穷大 // 计算每架飞机相对于当前中心的偏移量 const commands = this.planeList.map(p => { const pos = p?.planeState?.position @@ -216,12 +217,22 @@ export default { const newLat = targetLat + offsetLat const newAlt = targetAlt + offsetAlt + if (newAlt < minTargetAlt) { + minTargetAlt = newAlt + } + return { macadd: p.macadd, cmd: `{guidedMode:{lon:${newLon.toFixed(7)},lat:${newLat.toFixed(7)},alt:${newAlt.toFixed(1)}}}` } }).filter(Boolean) + // 最矮的飞机小于地面高度 返回 + if (minTargetAlt < 0) { + this.$message.warning(`指令已取消:最矮飞机将飞到地面以下(最低高度 ${minTargetAlt.toFixed(1)} 米)`) + return + } + // 发送控制指令 commands.forEach(({ macadd, cmd }) => { mqtt.publishFun(`cmd/${macadd}`, cmd) @@ -307,10 +318,19 @@ export default { deep: true }, /** - * @description: 侧边栏显隐 + * @description: 侧边栏缩进有变化时 地图重新自适应 */ - isCollapse () { - return this.$store.state.app.isCollapse + isCollapse: { + handler (val) { + if (val) { + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) + } + }, + deep: true } } } diff --git a/src/views/layout/components/main/route/add.vue b/src/views/layout/components/main/route/add.vue index 67e4f01..15b1864 100644 --- a/src/views/layout/components/main/route/add.vue +++ b/src/views/layout/components/main/route/add.vue @@ -80,6 +80,12 @@ export default { */ routeList () { return this.$store.state.routeList + }, + /** + * @description: 侧边栏显隐 + */ + isCollapse () { + return this.$store.state.app.isCollapse } }, methods: { @@ -169,6 +175,21 @@ export default { watch: { routeList () { this.initPage()// 初始化页面 + }, + /** + * @description: 侧边栏缩进有变化时 地图重新自适应 + */ + isCollapse: { + handler (val) { + if (val) { + setTimeout(() => { + this.$nextTick(() => { + this.$refs.mapbox.handleResize() + }) + }, 500) + } + }, + deep: true } }, created () { diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index a9dcef4..049d3b7 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -220,7 +220,7 @@ export default { plane.planeState[key] = homePosition } else if (key === 'statusText') { /* 飞控信息 插入日志 */ - this.$store.dispatch('fetchLog', { content: jsonData[key], color: '#f57c00' }) + this.$store.dispatch('fetchLog', { content: `${plane.name}--${jsonData[key]}`, color: '#f57c00' }) } else { plane.planeState[key] = jsonData[key] // 按订阅信息 刷新飞机状态 }