fix(playback-websocket): 增强机器人数据更新逻辑,确保状态和充电信息的准确传递
This commit is contained in:
parent
1fbdb5efcb
commit
260ac45cb7
@ -171,7 +171,7 @@ export function usePlaybackWebSocket(editorService: ShallowRef<EditorService | u
|
|||||||
updates.forEach(({ id, data }) => {
|
updates.forEach(({ id, data }) => {
|
||||||
const robotExists = editor.checkRobotById(id);
|
const robotExists = editor.checkRobotById(id);
|
||||||
if (robotExists) {
|
if (robotExists) {
|
||||||
const { x, y, angle, state, ...rest } = data;
|
const { x, y, angle, state, isCharging, isCarrying, canOrder, ...rest } = data;
|
||||||
const pen = editor.getPenById(id);
|
const pen = editor.getPenById(id);
|
||||||
const currentState = pen?.robot?.state;
|
const currentState = pen?.robot?.state;
|
||||||
// 将业务数据和位置数据合并到一个对象中,通过 setValue 一次性更新
|
// 将业务数据和位置数据合并到一个对象中,通过 setValue 一次性更新
|
||||||
@ -186,10 +186,17 @@ export function usePlaybackWebSocket(editorService: ShallowRef<EditorService | u
|
|||||||
...rest,
|
...rest,
|
||||||
// 增加更严格的校验:确保 state 的值存在于 RobotState 枚举中
|
// 增加更严格的校验:确保 state 的值存在于 RobotState 枚举中
|
||||||
state: RobotState[state] ? state : (currentState ?? RobotState.未知),
|
state: RobotState[state] ? state : (currentState ?? RobotState.未知),
|
||||||
|
// 确保传递载货和充电状态
|
||||||
|
isCharging: isCharging ?? 0,
|
||||||
|
isCarrying: isCarrying ?? 0,
|
||||||
|
canOrder: canOrder ?? true,
|
||||||
}, // 将业务数据挂载到图元的 robot 属性上
|
}, // 将业务数据挂载到图元的 robot 属性上
|
||||||
},
|
},
|
||||||
{ render: false },
|
{ render: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 更新状态覆盖图标
|
||||||
|
editor.updateRobotStatusOverlay(id, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user