feat: 在运动监控页面中添加播放模式逻辑,优化场景标题动态更新和路由配置

This commit is contained in:
xudan 2025-10-09 11:45:33 +08:00
parent 58e0726a7f
commit de58022508
2 changed files with 28 additions and 15 deletions

View File

@ -35,20 +35,30 @@ const props = defineProps<Props>();
//#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<string>('');
const modeTitle = computed(() => {
if (isPlaybackMode.value) {
return '场景回放';
}
return isMonitorMode.value ? '场景监控' : '场景仿真';
});
//
const leftCollapsed = ref<boolean>(false);
//
watch(
isMonitorMode,
(isMonitor) => {
const mode = isMonitor ? '场景监控' : '场景仿真';
document.title = mode;
modeTitle,
(newTitle) => {
document.title = newTitle;
},
{ immediate: true },
);
@ -60,10 +70,6 @@ const storageLocationService = shallowRef<StorageLocationService>();
const client = shallowRef<WebSocket>();
// Ctrl/Cmd+F
const leftSiderEl = shallowRef<HTMLElement>();
//#region Playback Mode
const mode = ref<'live' | 'playback'>('live');
const isPlaybackMode = computed(() => mode.value === 'playback');
const isPlaybackControllerVisible = ref<boolean>(true);
const selectedDate = ref<Dayjs | null>(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) => {
<a-layout class="full">
<a-layout-header class="p-16" style="height: 64px">
<a-flex justify="space-between" align="center">
<a-typography-text class="title">{{ title }}--{{ isMonitorMode ? '场景监控' : '场景仿真' }}</a-typography-text>
<a-typography-text class="title">{{ title }}--{{ modeTitle }}</a-typography-text>
<a-space align="center">
<a-button @click="backToCards"> 返回 </a-button>
<a-button type="primary" :loading="isSaving" @click="handleSaveViewState"> 保存比例 </a-button>
<a-divider type="vertical" />
<a-radio-group v-model:value="mode" button-style="solid">
<a-radio-button value="live">实时监控</a-radio-button>
<a-radio-button value="playback">历史回放</a-radio-button>
</a-radio-group>
<a-date-picker
v-if="isPlaybackMode"
:value="selectedDate"

View File

@ -33,6 +33,12 @@ export const ROUTES = Object.freeze<RouteRecordRaw[]>([
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({