清理获取车辆的定时器

This commit is contained in:
yyy 2025-06-12 16:13:19 +08:00
parent dbf7850eb0
commit 1747b773fc
2 changed files with 68 additions and 34 deletions

View File

@ -878,7 +878,7 @@ onMounted(() => {
robotListTimerRef.value = setInterval(() => {
if (document.hidden) return //
getRobotByFloorAndAreaList()
}, 5000)
}, 10000)
//
document.addEventListener('visibilitychange', () => {
@ -892,6 +892,21 @@ onUnmounted(() => {
document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
document.removeEventListener('mozfullscreenchange', handleFullscreenChange)
document.removeEventListener('MSFullscreenChange', handleFullscreenChange)
//
if (robotListTimerRef.value) {
clearInterval(robotListTimerRef.value)
robotListTimerRef.value = null
}
if (wsConnection.value) {
wsConnection.value.disconnect()
wsConnection.value = null
}
//
testCarList.value = []
robotByFloorAndAreaList.value = []
})
onBeforeUnmount(() => {
if (robotListTimerRef.value) {

View File

@ -2714,14 +2714,24 @@ const submitBatchCopyingFormSuccess = async (form) => {
const validNodes = newPoints.filter((node) => isValidNodeType(node.type))
const validRoutes = newRoutes.filter((route) => isValidRoute(route))
//
const calculateNewCoordinates = (x, y) => {
const newX = (Number(x) + Number(form.x)).toString()
const newY = (Number(y) + Number(form.y)).toString()
const actualPoint = disposeEventPoint(newX, newY)
return { newX, newY, actualPoint }
}
const newPointList = await Promise.all(
validNodes.map(async (node) => {
const newId = await MapApi.getNodeId()
nodeIdMap.set(node.id, newId)
const locationX = Number(node.locationX) + Number(form.x)
const locationY = Number(node.locationY) + Number(form.y)
const actualPoint = disposeEventPoint(locationX, locationY)
const {
newX: locationX,
newY: locationY,
actualPoint
} = calculateNewCoordinates(node.locationX, node.locationY)
const { sortNum, createTime, ...restNode } = node
@ -2733,14 +2743,14 @@ const submitBatchCopyingFormSuccess = async (form) => {
dataList = []
dataJson = ''
} else if (restNode.type === 2) {
dataList = restNode.dataList.map((item) => {
return {
locationDeep: item.locationDeep,
locationStorey: item.locationStorey,
locationWide: item.locationWide,
positionMapId: item.positionMapId
}
dataList = restNode.dataList.map(
({ locationDeep, locationStorey, locationWide, positionMapId }) => ({
locationDeep,
locationStorey,
locationWide,
positionMapId
})
)
dataJson = JSON.stringify(dataList)
} else if (restNode.type === 4) {
dataObj = {
@ -2771,21 +2781,27 @@ const submitBatchCopyingFormSuccess = async (form) => {
//
if (nodeIdMap.has(route.startingPointId)) {
const { newX, newY, actualPoint } = calculateNewCoordinates(
route.startPointX,
route.startPointY
)
newRoute.startingPointId = nodeIdMap.get(route.startingPointId)
newRoute.startPointX = (Number(route.startPointX) + Number(form.x)).toString()
newRoute.startPointY = (Number(route.startPointY) + Number(form.y)).toString()
const actualStartPoint = disposeEventPoint(newRoute.startPointX, newRoute.startPointY)
newRoute.actualStartPointX = actualStartPoint.actualLocationX
newRoute.actualStartPointY = actualStartPoint.actualLocationY
newRoute.startPointX = newX
newRoute.startPointY = newY
newRoute.actualStartPointX = actualPoint.actualLocationX
newRoute.actualStartPointY = actualPoint.actualLocationY
//
if (route.method == 1) {
newRoute.beginControlX = (Number(route.beginControlX) + Number(form.x)).toString()
newRoute.beginControlY = (Number(route.beginControlY) + Number(form.y)).toString()
const actualBeginControl = disposeEventPoint(newRoute.beginControlX, newRoute.beginControlY)
newRoute.actualBeginControlX = actualBeginControl.actualLocationX
newRoute.actualBeginControlY = actualBeginControl.actualLocationY
const {
newX: controlX,
newY: controlY,
actualPoint: controlPoint
} = calculateNewCoordinates(route.beginControlX, route.beginControlY)
newRoute.beginControlX = controlX
newRoute.beginControlY = controlY
newRoute.actualBeginControlX = controlPoint.actualLocationX
newRoute.actualBeginControlY = controlPoint.actualLocationY
} else {
newRoute.beginControlX = 0
newRoute.beginControlY = 0
@ -2796,21 +2812,24 @@ const submitBatchCopyingFormSuccess = async (form) => {
//
if (nodeIdMap.has(route.endPointId)) {
const { newX, newY, actualPoint } = calculateNewCoordinates(route.endPointX, route.endPointY)
newRoute.endPointId = nodeIdMap.get(route.endPointId)
newRoute.endPointX = (Number(route.endPointX) + Number(form.x)).toString()
newRoute.endPointY = (Number(route.endPointY) + Number(form.y)).toString()
const actualEndPoint = disposeEventPoint(newRoute.endPointX, newRoute.endPointY)
newRoute.actualEndPointX = actualEndPoint.actualLocationX
newRoute.actualEndPointY = actualEndPoint.actualLocationY
newRoute.endPointX = newX
newRoute.endPointY = newY
newRoute.actualEndPointX = actualPoint.actualLocationX
newRoute.actualEndPointY = actualPoint.actualLocationY
//
if (route.method == 1) {
newRoute.endControlX = (Number(route.endControlX) + Number(form.x)).toString()
newRoute.endControlY = (Number(route.endControlY) + Number(form.y)).toString()
const actualEndControl = disposeEventPoint(newRoute.endControlX, newRoute.endControlY)
newRoute.actualEndControlX = actualEndControl.actualLocationX
newRoute.actualEndControlY = actualEndControl.actualLocationY
const {
newX: controlX,
newY: controlY,
actualPoint: controlPoint
} = calculateNewCoordinates(route.endControlX, route.endControlY)
newRoute.endControlX = controlX
newRoute.endControlY = controlY
newRoute.actualEndControlX = controlPoint.actualLocationX
newRoute.actualEndControlY = controlPoint.actualLocationY
} else {
newRoute.endControlX = 0
newRoute.endControlY = 0