From a308ab67c4d18926ace744f64f8e454f6a9d8b4f Mon Sep 17 00:00:00 2001 From: tk Date: Thu, 19 Sep 2024 11:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afix=20=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E5=80=BC=E7=9A=84bug=20=E3=80=90=E5=8E=9F=20?= =?UTF-8?q?=20=E5=9B=A0=E3=80=91=EF=BC=9AshowTooltip=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=20=E8=A1=A8=E8=BE=BE=E5=BC=8F=E9=87=8C=E9=9D=A2=20?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=80=BC=E4=B8=8D=E6=98=8E=E7=A1=AE=20?= =?UTF-8?q?=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=E6=98=8E?= =?UTF-8?q?=E7=A1=AE=20=E5=80=BC=E6=98=AF=E5=90=A6=E4=B8=BA0=20=E3=80=90?= =?UTF-8?q?=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- src/components/BatteryStatus.vue | 2 +- src/components/ControllerTabs.vue | 40 ++++++++++++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/components/BatteryStatus.vue b/src/components/BatteryStatus.vue index 52455cc..7bed634 100644 --- a/src/components/BatteryStatus.vue +++ b/src/components/BatteryStatus.vue @@ -73,7 +73,7 @@ export default { }, // 控制 Tooltip 显示的条件 showTooltip () { - return this.batteryRemainingPower || this.endurance + return Number(this.batteryRemainingPower) !== 0 || Number(this.endurance) !== 0 }, // 剩余电量 (百分比) batteryRemaining () { diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index 415e3f4..7adac76 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -90,7 +90,8 @@ 关闭 - 写入 + 写入 @@ -138,20 +139,21 @@ icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="checkQuest"> 上传航点 --> - + 准备任务 - + 航点写入中··· 解锁中... - 执行任务 @@ -642,16 +644,15 @@ export default { console.log(error.message) // 处理检查失败的情况 }) }, - /** - * @description: 准备任务 先检查合法性,再从飞机反馈中 看有无写入航点 ,最后解锁飞机 - */ - prepareQuest () { - if (Number(this.plane.planeState.questState) === 1) { - this.checkQuest()// 检查合法性 - } - if (Number(this.plane.planeState.questState) === 4) { - this.publishFun('{unlock:1}')// 解锁飞机 - } + /** 等待上传完航点之后 解锁飞机 */ + watchUnlock () { + // 使用 Vue 的 $watch 方法监听 planeState.questState 的变化 + const unwatch = this.$watch(() => this.plane.planeState.questState, (newVal) => { + if (Number(newVal) === 4) { // 如果 questState 变为 4 + this.publishFun('{unlock:1}') // 解锁飞机 + unwatch() // 解除监听,防止多次触发 + } + }) }, /** * @description: 正在执行的任务 重新上传航线 @@ -677,8 +678,8 @@ export default { } }) routeData = JSON.stringify(routeData)// 重新序列化 - // 发送航点信息主题 - this.publishFun(routeData) + this.publishFun(routeData) // 发送航点信息主题 + this.watchUnlock()// 等待飞机写完航点 解锁飞机 } catch (error) { this.$message.error('操作失败,航线异常') } @@ -743,6 +744,7 @@ export default { }) if (res.data.status === 1) { this.publishFun(routeData)// 发送航点信息主题 + this.watchUnlock()// 等待飞机写完航点 解锁飞机 } }, /**