修复实时地图页面离开页面后轮询还在执行问题

This commit is contained in:
yyy 2025-04-08 10:32:34 +08:00
parent c8b456adb3
commit b8b174ce50

View File

@ -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>