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

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
// 线 testCarList
const robotByFloorAndAreaList = ref([]) //
const robotListTimer = ref(5) //
const robotListTimerRef = ref(null) //
const getRobotByFloorAndAreaList = () => {
if (robotListTimerRef.value) {
clearInterval(robotListTimerRef.value)
robotListTimerRef.value = null
}
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) => {
@ -1056,10 +1050,8 @@ const carDbClick = (item, index) => {
defineExpose({ getMapData }) // open
onMounted(() => {})
onBeforeUnmount(() => {
if (robotListTimerRef.value) {
clearInterval(robotListTimerRef.value)
robotListTimerRef.value = null
}
})
</script>