【类 型】:fix

【原  因】:1地图组件 经纬度显示反了  2概况统计组件 由于now并不实时更新 改用setIterval来更新 总时长
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
air 2025-06-25 19:51:14 +08:00
parent f7a52217a0
commit 686f325825
2 changed files with 15 additions and 16 deletions

View File

@ -1043,8 +1043,8 @@ export default {
<p><strong>电压:</strong> ${stateObj.voltagBattery ?? '--'} V</p> <p><strong>电压:</strong> ${stateObj.voltagBattery ?? '--'} V</p>
<p><strong>电流:</strong> ${stateObj.currentBattery ?? '--'} A</p> <p><strong>电流:</strong> ${stateObj.currentBattery ?? '--'} A</p>
<p><strong>高度:</strong> ${lastPos[2] ?? '--'} </p> <p><strong>高度:</strong> ${lastPos[2] ?? '--'} </p>
<p><strong>:</strong> ${lastPos[0] ?? '--'}°</p> <p><strong>:</strong> ${lastPos[0] ?? '--'}°</p>
<p><strong>:</strong> ${lastPos[1] ?? '--'}°</p> <p><strong>:</strong> ${lastPos[1] ?? '--'}°</p>
<p><strong>对地速度:</strong> ${stateObj.groundSpeed ?? '--'} /</p> <p><strong>对地速度:</strong> ${stateObj.groundSpeed ?? '--'} /</p>
` `

View File

@ -44,6 +44,8 @@ export default {
name: 'Statistics', name: 'Statistics',
data () { data () {
return { return {
now: Math.floor(Date.now() / 1000), //
timer: null
} }
}, },
props: { props: {
@ -52,8 +54,6 @@ export default {
deep: true deep: true
} }
}, },
components: {
},
computed: { computed: {
totalCount () { totalCount () {
return Object.keys(this.planes || {}).length return Object.keys(this.planes || {}).length
@ -62,13 +62,12 @@ export default {
return Object.values(this.planes || {}).filter(p => p.planeState?.online).length return Object.values(this.planes || {}).filter(p => p.planeState?.online).length
}, },
totalWorkingDuration () { totalWorkingDuration () {
// - startTime // 使 this.now
const now = Math.floor(Date.now() / 1000)
return Object.values(this.planes || {}).reduce((total, p) => { return Object.values(this.planes || {}).reduce((total, p) => {
const s = p.planeState?.flyDataSave?.startTime const s = p.planeState?.flyDataSave?.startTime
const isUnlock = p.planeState?.isUnlock const isUnlock = p.planeState?.isUnlock
if (isUnlock && s) { if (isUnlock && s) {
return total + (now - s) return total + (this.now - s)
} }
return total return total
}, 0) }, 0)
@ -101,19 +100,18 @@ export default {
const s = (sec % 60).toString().padStart(2, '0') const s = (sec % 60).toString().padStart(2, '0')
return `${h}:${m}:${s}` return `${h}:${m}:${s}`
} }
},
watch: {
},
methods: {
}, },
created () { created () {
// now computed
this.timer = setInterval(() => {
this.now = Math.floor(Date.now() / 1000)
}, 1000)
}, },
destroyed () { beforeDestroy () {
clearInterval(this.timer)
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -154,7 +152,8 @@ export default {
.plane-mode-text { .plane-mode-text {
display: inline-block; display: inline-block;
white-space: nowrap; /* 防止内容换行 */ white-space: nowrap;
/* 防止内容换行 */
} }
.item { .item {