【类 型】:fix
【原 因】:1 地图组件经纬度反了 2.概况状态 总时长now不能实时更新 更为用setInterval 【过 程】: 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
a7b37c27c8
commit
93d7dc044d
@ -1043,8 +1043,8 @@ export default {
|
||||
<p><strong>电压:</strong> ${stateObj.voltagBattery ?? '--'} V</p>
|
||||
<p><strong>电流:</strong> ${stateObj.currentBattery ?? '--'} A</p>
|
||||
<p><strong>高度:</strong> ${lastPos[2] ?? '--'} 米</p>
|
||||
<p><strong>纬度:</strong> ${lastPos[0] ?? '--'}°</p>
|
||||
<p><strong>经度:</strong> ${lastPos[1] ?? '--'}°</p>
|
||||
<p><strong>经度:</strong> ${lastPos[0] ?? '--'}°</p>
|
||||
<p><strong>纬度:</strong> ${lastPos[1] ?? '--'}°</p>
|
||||
<p><strong>对地速度:</strong> ${stateObj.groundSpeed ?? '--'} 米/秒</p>
|
||||
`
|
||||
|
||||
|
@ -44,6 +44,8 @@ export default {
|
||||
name: 'Statistics',
|
||||
data () {
|
||||
return {
|
||||
now: Math.floor(Date.now() / 1000), // 当前秒级时间戳,用于实时更新
|
||||
timer: null
|
||||
}
|
||||
},
|
||||
props: {
|
||||
@ -52,8 +54,6 @@ export default {
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
components: {
|
||||
},
|
||||
computed: {
|
||||
totalCount () {
|
||||
return Object.keys(this.planes || {}).length
|
||||
@ -62,13 +62,12 @@ export default {
|
||||
return Object.values(this.planes || {}).filter(p => p.planeState?.online).length
|
||||
},
|
||||
totalWorkingDuration () {
|
||||
// 所有处于解锁状态的飞机,加上当前时长(当前时间 - startTime)
|
||||
const now = Math.floor(Date.now() / 1000)
|
||||
// 使用 this.now 保证每秒计算更新
|
||||
return Object.values(this.planes || {}).reduce((total, p) => {
|
||||
const s = p.planeState?.flyDataSave?.startTime
|
||||
const isUnlock = p.planeState?.isUnlock
|
||||
if (isUnlock && s) {
|
||||
return total + (now - s)
|
||||
return total + (this.now - s)
|
||||
}
|
||||
return total
|
||||
}, 0)
|
||||
@ -101,19 +100,18 @@ export default {
|
||||
const s = (sec % 60).toString().padStart(2, '0')
|
||||
return `${h}:${m}:${s}`
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
created () {
|
||||
// 启动定时器,每秒刷新 now,从而触发 computed 更新
|
||||
this.timer = setInterval(() => {
|
||||
this.now = Math.floor(Date.now() / 1000)
|
||||
}, 1000)
|
||||
},
|
||||
destroyed () {
|
||||
beforeDestroy () {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
Loading…
Reference in New Issue
Block a user