feat(movement-supervision): 优化楼层切换体验,异步处理机器人初始化与WebSocket连接

This commit is contained in:
xudan 2025-10-22 15:07:33 +08:00
parent d2eb594099
commit 2895d59e2a
3 changed files with 22 additions and 10 deletions

View File

@ -4,5 +4,5 @@ ENV_WEBSOCKET_BASE=/ws
ENV_STORAGE_WEBSOCKET_BASE=/vwedWs
# 开发环境token配置 - 可以手动设置或从另一个项目获取后填入
ENV_DEV_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjEyMjQyMDUsInVzZXJuYW1lIjoiYWRtaW4ifQ.VJh59eh3inhKqqupFvxOnSGkJd0zUf_PmBmRMyiQKX0
ENV_DEV_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjEyMzM2NzMsInVzZXJuYW1lIjoiYWRtaW4ifQ.KPflinK1a3dxwjkEuZTfyVnEe7oX1LwmzBYn0-hSogc
ENV_DEV_TENANT_ID=1000

View File

@ -649,20 +649,25 @@ const handleAutoSaveAndRestoreViewState = async () => {
const handleFloorChange = async (value: any) => {
const newFloorIndex = value as number;
if (editor.value && floorScenes.value[newFloorIndex]) {
// 1)
await editor.value.load(floorScenes.value[newFloorIndex]);
//
await editor.value.initRobots();
// WebSocket
if (mode.value === 'live') {
await monitorScene();
}
// map-toolbar.vue
// 2) WS/
try {
const { centerX, centerY } = calculateCenterPoint(editor.value);
jumpToPosition(editor.value, centerX, centerY, false, 0.05);
await jumpToPosition(editor.value, centerX, centerY, false, 0.05);
} catch {
// ignore
}
// 3)
// 3.1
Promise.resolve(editor.value.initRobots()).catch(() => void 0);
// 3.2 WebSocket
if (mode.value === 'live') {
void monitorScene();
}
}
};
//#endregion

View File

@ -656,7 +656,7 @@ const selectRobot = (id: string) => {
editor.value?.inactive();
};
const { saveViewState, autoSaveAndRestoreViewState, isSaving } = useViewState();
const { saveViewState, autoSaveAndRestoreViewState, isSaving, jumpToPosition, calculateCenterPoint } = useViewState();
const handleSaveViewState = async () => {
if (!editor.value) return;
@ -707,6 +707,13 @@ const handleFloorChange = async (value: any) => {
undefined,
floorImportFlags.value[newFloorIndex] ?? false,
);
//
try {
const { centerX, centerY } = calculateCenterPoint(editor.value);
await jumpToPosition(editor.value, centerX, centerY, false, 0.05);
} catch {
// ignore
}
} else {
currentFloorIndex.value = newFloorIndex;
previousFloorIndex.value = newFloorIndex;