web-map/src/pages/scene-editor.vue

62 lines
1.6 KiB
Vue
Raw Normal View History

2025-04-27 00:05:18 +08:00
<script setup lang="ts">
2025-04-30 00:17:09 +08:00
import type { RobotGroup } from '@api/robot';
import { getSceneById } from '@api/scene';
2025-04-27 00:05:18 +08:00
import { EditorService } from '@core/editor.service';
2025-04-30 00:17:09 +08:00
import { isEmpty } from 'lodash-es';
import { watch } from 'vue';
import { ref } from 'vue';
2025-04-27 00:05:18 +08:00
import { onMounted, provide, shallowRef } from 'vue';
const EDITOR_KEY = Symbol('editor-key');
type Props = {
id: string;
};
const props = defineProps<Props>();
2025-04-30 00:17:09 +08:00
const title = ref<string>('');
const groups = ref<RobotGroup[]>([]);
const map = ref<string>('');
onMounted(() => {
getSceneById(props.id).then((res) => {
title.value = res?.label ?? '';
groups.value = res?.robotGroups ?? [];
map.value = res?.map ?? '';
});
});
watch(map, (v) => {
editor.value?.load(v, !editable.value);
});
2025-04-27 00:05:18 +08:00
const container = shallowRef<HTMLDivElement>();
const editor = shallowRef<EditorService>();
provide(EDITOR_KEY, editor);
onMounted(() => {
editor.value = new EditorService(container.value!);
});
2025-04-30 00:17:09 +08:00
const editable = ref<boolean>(false);
2025-04-27 00:05:18 +08:00
</script>
<template>
<a-layout class="full">
2025-04-30 00:17:09 +08:00
<a-layout-header class="ph-16" style="height: 64px">
<a-flex justify="space-between">
<a-typography-text strong>{{ title }}</a-typography-text>
</a-flex>
</a-layout-header>
2025-04-27 00:05:18 +08:00
<a-layout>
<a-layout-sider>
<RobotList v-if="editor" :editor="EDITOR_KEY" />
</a-layout-sider>
<a-layout-content>
<div ref="container" class="full"></div>
</a-layout-content>
2025-04-28 00:43:33 +08:00
<a-layout-sider>{{ $t('查询') }}</a-layout-sider>
2025-04-27 00:05:18 +08:00
</a-layout>
</a-layout>
</template>
<!-- <style scoped lang="scss"></style> -->