From d975357f04267c20a4b08228816499a3b9ddea53 Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 11 Dec 2025 16:33:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(elevator):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E8=B0=83=E8=AF=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=92=8C=E5=B7=B2=E6=B3=A8=E9=87=8A=E7=9A=84=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=B8=85=E7=90=86=E5=87=BD=E6=95=B0=E4=BB=A5=E7=B2=BE?= =?UTF-8?q?=E7=AE=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/movement-supervision.vue | 5 ---- src/stores/elevator.store.ts | 45 +++++++++--------------------- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/pages/movement-supervision.vue b/src/pages/movement-supervision.vue index 2db5dc0..ce3c0d4 100644 --- a/src/pages/movement-supervision.vue +++ b/src/pages/movement-supervision.vue @@ -570,11 +570,6 @@ onMounted(async () => { const stateIndex = elevatorMockTick % elevatorStates.length; const state = elevatorStates[stateIndex]; - console.log(`[开发环境] 电梯状态变化 #${elevatorMockTick}:`, { - floor: state.floor, - direction: ['未知', '停止', '向上', '向下'][state.direction], - doorStatus: ['未知', '关', '开关门中', '开'][state.doorStatus] - }); elevatorStore.handleElevatorWebSocketData({ id: '1998661793706377218', diff --git a/src/stores/elevator.store.ts b/src/stores/elevator.store.ts index f6e84f7..ac5fe0a 100644 --- a/src/stores/elevator.store.ts +++ b/src/stores/elevator.store.ts @@ -50,7 +50,7 @@ export const useElevatorStore = defineStore('elevator', () => { // 动画相关状态 const movingElevators = ref>(new Set()); const animationFrameId = ref(null); - const frameCount = ref(0); // 调试用帧计数器 + const frameCount = ref(0); // 帧计数器 // ========== 方法 ========== @@ -65,25 +65,6 @@ export const useElevatorStore = defineStore('elevator', () => { console.log('🛗 电梯Store: 编辑器服务已设置,等待场景加载后构建映射'); }; - /** - * 清理无效的运动电梯(连接断开或方向非运动状态) - */ - const cleanupInvalidMovingElevators = () => { - let hasChanges = false; - - for (const deviceId of movingElevators.value) { - const elevatorData = elevators.value.get(deviceId); - // 如果电梯数据不存在、连接断开、或方向不是运动状态,则移除 - if (!elevatorData || !elevatorData.isConnected || - (elevatorData.elevatorDirection !== 2 && elevatorData.elevatorDirection !== 3)) { - movingElevators.value.delete(deviceId); - hasChanges = true; - console.log(`🛗 清理无效运动电梯: ${deviceId}, 连接: ${elevatorData?.isConnected}, 方向: ${elevatorData?.elevatorDirection}`); - } - } - - return hasChanges; - }; /** * 启动动画循环(如果尚未启动) @@ -95,24 +76,24 @@ export const useElevatorStore = defineStore('elevator', () => { frameCount.value++; if (editorService.value) { // 清理无效的运动电梯 - const hadInvalid = cleanupInvalidMovingElevators(); + // const hadInvalid = cleanupInvalidMovingElevators(); if (movingElevators.value.size > 0) { // 有运动电梯,触发渲染 editorService.value.render(); - // 每60帧打印一次调试信息 - if (frameCount.value % 60 === 0) { - console.log(`🛗 动画循环运行中,帧: ${frameCount.value}, 运动电梯: ${movingElevators.value.size}`); - } + // 每60帧打印一次调试信息(已禁用) + // if (frameCount.value % 60 === 0) { + // console.log(`🛗 动画循环运行中,帧: ${frameCount.value}, 运动电梯: ${movingElevators.value.size}`); + // } animationFrameId.value = requestAnimationFrame(loop); } else { // 无运动电梯,停止循环 - if (hadInvalid) { - console.log('🛗 所有运动电梯已无效,停止动画循环'); - } - console.log(`🛗 停止电梯动画循环,总帧数: ${frameCount.value}`); + // if (hadInvalid) { + // console.log('🛗 所有运动电梯已无效,停止动画循环'); + // } + // console.log(`🛗 停止电梯动画循环,总帧数: ${frameCount.value}`); animationFrameId.value = null; frameCount.value = 0; } @@ -122,7 +103,7 @@ export const useElevatorStore = defineStore('elevator', () => { } }; animationFrameId.value = requestAnimationFrame(loop); - console.log('🛗 启动电梯动画循环'); + // console.log('🛗 启动电梯动画循环'); }; /** @@ -149,10 +130,10 @@ export const useElevatorStore = defineStore('elevator', () => { if (isMoving && !wasMoving) { movingElevators.value.add(deviceId); startAnimationLoop(); - console.log(`🛗 添加运动电梯: ${deviceId}, 方向: ${elevatorData.elevatorDirection}`); + // console.log(`🛗 添加运动电梯: ${deviceId}, 方向: ${elevatorData.elevatorDirection}`); } else if (!isMoving && wasMoving) { movingElevators.value.delete(deviceId); - console.log(`🛗 移除运动电梯: ${deviceId}, 原因: ${elevatorData ? '连接断开或方向改变' : '数据不存在'}`); + // console.log(`🛗 移除运动电梯: ${deviceId}, 原因: ${elevatorData ? '连接断开或方向改变' : '数据不存在'}`); if (movingElevators.value.size === 0) { stopAnimationLoop(); }