修复实时地图页面离开页面后轮询还在执行问题
This commit is contained in:
parent
c8b456adb3
commit
b8b174ce50
@ -743,22 +743,16 @@ const linkWebSocket = (url) => {
|
|||||||
// 现在车辆的逻辑是这样 websoket map_push类型推送消息 每次推送新车 我就添加到车辆列表中 testCarList 不删除车辆
|
// 现在车辆的逻辑是这样 websoket map_push类型推送消息 每次推送新车 我就添加到车辆列表中 testCarList 不删除车辆
|
||||||
// 每几秒轮询调用查看当前楼层区域的在线车辆 如果不存在 则再把testCarList 中的车辆删除
|
// 每几秒轮询调用查看当前楼层区域的在线车辆 如果不存在 则再把testCarList 中的车辆删除
|
||||||
const robotByFloorAndAreaList = ref([]) // 机器人列表
|
const robotByFloorAndAreaList = ref([]) // 机器人列表
|
||||||
const robotListTimer = ref(5) //轮询时间
|
|
||||||
const robotListTimerRef = ref(null) //轮询定时器
|
const robotListTimerRef = ref(null) //轮询定时器
|
||||||
const getRobotByFloorAndAreaList = () => {
|
const getRobotByFloorAndAreaList = () => {
|
||||||
if (robotListTimerRef.value) {
|
MapApi.getRobotByFloorAndArea({ floor: imgBgObj.floor, area: imgBgObj.area }).then((res) => {
|
||||||
clearInterval(robotListTimerRef.value)
|
robotByFloorAndAreaList.value = res
|
||||||
robotListTimerRef.value = null
|
if (testCarList.value.length) {
|
||||||
}
|
testCarList.value = filterArrayByRobotNo(testCarList.value, robotByFloorAndAreaList.value)
|
||||||
robotListTimerRef.value = setInterval(() => {
|
}
|
||||||
MapApi.getRobotByFloorAndArea({ floor: imgBgObj.floor, area: imgBgObj.area }).then((res) => {
|
})
|
||||||
robotByFloorAndAreaList.value = res
|
|
||||||
if (testCarList.value.length) {
|
|
||||||
testCarList.value = filterArrayByRobotNo(testCarList.value, robotByFloorAndAreaList.value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, robotListTimer.value * 1000)
|
|
||||||
}
|
}
|
||||||
|
robotListTimerRef.value = setInterval(getRobotByFloorAndAreaList, 5000)
|
||||||
|
|
||||||
// 删掉不在线的车辆
|
// 删掉不在线的车辆
|
||||||
const filterArrayByRobotNo = (arr1, arr2) => {
|
const filterArrayByRobotNo = (arr1, arr2) => {
|
||||||
@ -1056,10 +1050,8 @@ const carDbClick = (item, index) => {
|
|||||||
defineExpose({ getMapData }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ getMapData }) // 提供 open 方法,用于打开弹窗
|
||||||
onMounted(() => {})
|
onMounted(() => {})
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (robotListTimerRef.value) {
|
clearInterval(robotListTimerRef.value)
|
||||||
clearInterval(robotListTimerRef.value)
|
robotListTimerRef.value = null
|
||||||
robotListTimerRef.value = null
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user