feat: 优化运动监控页面的日期选择逻辑,增强场景加载后的机器人初始化流程
This commit is contained in:
parent
b2fc2d8d73
commit
b1d8806a59
@ -6,6 +6,7 @@ import { isNil } from 'lodash-es';
|
|||||||
import { computed, onMounted, onUnmounted, provide, ref, type ShallowRef, shallowRef, watch } from 'vue';
|
import { computed, onMounted, onUnmounted, provide, ref, type ShallowRef, shallowRef, watch } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import type { RobotRealtimeInfo } from '../apis/robot';
|
||||||
import { getSceneByGroupId, getSceneById, monitorRealSceneById, monitorSceneById } from '../apis/scene';
|
import { getSceneByGroupId, getSceneById, monitorRealSceneById, monitorSceneById } from '../apis/scene';
|
||||||
import expandIcon from '../assets/icons/png/expand.png';
|
import expandIcon from '../assets/icons/png/expand.png';
|
||||||
import foldIcon from '../assets/icons/png/fold.png';
|
import foldIcon from '../assets/icons/png/fold.png';
|
||||||
@ -71,7 +72,7 @@ const client = shallowRef<WebSocket>();
|
|||||||
// 左侧边栏元素引用(用于 Ctrl/Cmd+F 聚焦搜索框)
|
// 左侧边栏元素引用(用于 Ctrl/Cmd+F 聚焦搜索框)
|
||||||
const leftSiderEl = shallowRef<HTMLElement>();
|
const leftSiderEl = shallowRef<HTMLElement>();
|
||||||
const isPlaybackControllerVisible = ref<boolean>(true);
|
const isPlaybackControllerVisible = ref<boolean>(true);
|
||||||
const selectedDate = ref<Dayjs | null>(null);
|
const selectedDate = ref<Dayjs>();
|
||||||
|
|
||||||
const playback = usePlaybackWebSocket(editor);
|
const playback = usePlaybackWebSocket(editor);
|
||||||
|
|
||||||
@ -85,9 +86,16 @@ watch(mode, async (newMode) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDateChange = (date: Dayjs) => {
|
watch(playback.sceneJson, async (newJson) => {
|
||||||
|
if (newJson) {
|
||||||
|
await editor.value?.load(newJson);
|
||||||
|
// [关键修复] 场景加载后,立即重新初始化机器人
|
||||||
|
await editor.value?.initRobots();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedDate, (date) => {
|
||||||
if (date) {
|
if (date) {
|
||||||
selectedDate.value = date;
|
|
||||||
const startOfDayTimestamp = date.startOf('day').valueOf();
|
const startOfDayTimestamp = date.startOf('day').valueOf();
|
||||||
playback.seek(startOfDayTimestamp);
|
playback.seek(startOfDayTimestamp);
|
||||||
// The total duration is now relative to the start of the day
|
// The total duration is now relative to the start of the day
|
||||||
@ -95,7 +103,7 @@ const handleDateChange = (date: Dayjs) => {
|
|||||||
// Set current time to the beginning of the selected day for the slider
|
// Set current time to the beginning of the selected day for the slider
|
||||||
playback.currentTime.value = startOfDayTimestamp;
|
playback.currentTime.value = startOfDayTimestamp;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
const handleSeek = (relativeTime: number) => {
|
const handleSeek = (relativeTime: number) => {
|
||||||
if (selectedDate.value) {
|
if (selectedDate.value) {
|
||||||
@ -552,9 +560,7 @@ const focusFindKeydownHandler = (event: KeyboardEvent) => {
|
|||||||
if (input) {
|
if (input) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
input.focus();
|
input.focus();
|
||||||
try {
|
input.select?.();
|
||||||
input.select?.();
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,12 +589,7 @@ const handleGlobalKeydown = (event: KeyboardEvent) => {
|
|||||||
<a-button type="primary" :loading="isSaving" @click="handleSaveViewState"> 保存比例 </a-button>
|
<a-button type="primary" :loading="isSaving" @click="handleSaveViewState"> 保存比例 </a-button>
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
|
|
||||||
<a-date-picker
|
<a-date-picker v-if="isPlaybackMode" v-model:value="selectedDate" placeholder="请选择回放日期" />
|
||||||
v-if="isPlaybackMode"
|
|
||||||
:value="selectedDate"
|
|
||||||
@change="handleDateChange"
|
|
||||||
placeholder="请选择回放日期"
|
|
||||||
/>
|
|
||||||
</a-space>
|
</a-space>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-layout-header>
|
</a-layout-header>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user