diff --git a/src/pages/movement-supervision.vue b/src/pages/movement-supervision.vue index 1a29daa..09c1135 100644 --- a/src/pages/movement-supervision.vue +++ b/src/pages/movement-supervision.vue @@ -35,20 +35,30 @@ const props = defineProps(); //#region 响应式状态定义 // 获取路由信息以判断当前模式 const route = useRoute(); + +//#region Playback Mode +const mode = computed(() => (route.path.includes('/playback') ? 'playback' : 'live')); +const isPlaybackMode = computed(() => mode.value === 'playback'); const isMonitorMode = computed(() => route.path.includes('/monitor')); // 场景标题 const title = ref(''); +const modeTitle = computed(() => { + if (isPlaybackMode.value) { + return '场景回放'; + } + return isMonitorMode.value ? '场景监控' : '场景仿真'; +}); + // 左侧侧边栏折叠状态 const leftCollapsed = ref(false); // 监听标题变化,动态更新页面标题 watch( - isMonitorMode, - (isMonitor) => { - const mode = isMonitor ? '场景监控' : '场景仿真'; - document.title = mode; + modeTitle, + (newTitle) => { + document.title = newTitle; }, { immediate: true }, ); @@ -60,10 +70,6 @@ const storageLocationService = shallowRef(); const client = shallowRef(); // 左侧边栏元素引用(用于 Ctrl/Cmd+F 聚焦搜索框) const leftSiderEl = shallowRef(); - -//#region Playback Mode -const mode = ref<'live' | 'playback'>('live'); -const isPlaybackMode = computed(() => mode.value === 'playback'); const isPlaybackControllerVisible = ref(true); const selectedDate = ref(null); @@ -327,7 +333,13 @@ onMounted(() => { onMounted(async () => { await readScene(); await editor.value?.initRobots(); - await monitorScene(); + + if (mode.value === 'live') { + await monitorScene(); + } else { + playback.connect(props.sid); + } + storageLocationService.value?.startMonitoring({ interval: 1 }); // 自动保存和恢复视图状态 await handleAutoSaveAndRestoreViewState(); @@ -544,17 +556,12 @@ const handleGlobalKeydown = (event: KeyboardEvent) => { - {{ title }}--{{ isMonitorMode ? '场景监控' : '场景仿真' }} + {{ title }}--{{ modeTitle }} 返回 保存比例 - - 实时监控 - 历史回放 - - ([ props: true, component: () => import('@/movement-supervision.vue'), }, + { + name: '场景回放', + path: '/movement-supervision/:sid/playback/:id?', + props: true, + component: () => import('@/movement-supervision.vue'), + }, ]); export const router = createRouter({