diff --git a/src/views/mqtt/index.vue b/src/views/mqtt/index.vue
index 8d9bfb0..7ce8fb2 100644
--- a/src/views/mqtt/index.vue
+++ b/src/views/mqtt/index.vue
@@ -19,6 +19,11 @@ const password = $toRef(mqttStore, 'password')
const clientId = $toRef(mqttStore, 'clientId')
let loading = $ref(false)
+type CarPos = {
+ name: string
+ x: number
+ y: number
+}
const publish = reactive({
status: false,
index: 0,
@@ -38,7 +43,8 @@ const publish = reactive({
range: {
start: 0,
end: 0
- }
+ },
+ cars: [] as CarPos[]
})
const active = $ref('CLC_track')
@@ -107,6 +113,7 @@ async function doPublish() {
const interval = setInterval(() => {
if (exit) {
clearInterval(interval)
+ publish.cars = []
return
}
// if (publishing.pause) return
@@ -116,6 +123,7 @@ async function doPublish() {
let item = next()
// 判断下有没有内容,防止空指针
if (item[0]?.content?.[0]) {
+ let list = item[0].content
// 设置时间
publish.lastRawTimestamp = item[0].content[0].timeStamp
// 处理暂停等操作对时间的影响
@@ -126,7 +134,7 @@ async function doPublish() {
publish.lastTimestamp = publish.lastRawTimestamp + publish.timeOffset
// 由于时间发生变化,对所有车辆的时间进行替换
item = JSON.parse(JSON.stringify(item))
- const list = item[0].content
+ list = item[0].content
for (const it of list) it.timeStamp = it.timeStamp + offset
} else {
publish.lastTimestamp = publish.lastRawTimestamp
@@ -134,6 +142,11 @@ async function doPublish() {
if (publish.startTimestamp === 0) {
publish.startTimestamp = publish.lastTimestamp
}
+ publish.cars = list.map((it) => ({
+ name: it.global_track_id,
+ x: it.x / 1.6,
+ y: it.y / 0.9
+ }))
}
publish.onlineCars = item[0]?.content?.length ?? 0
publish.percentage = Number(((publish.index / (publish.count | 1)) * 100).toFixed(2))
@@ -202,7 +215,7 @@ function move(tick: number) {