diff --git a/src/layouts/LineLayout.vue b/src/layouts/LineLayout.vue index 08515eb..1103bc8 100644 --- a/src/layouts/LineLayout.vue +++ b/src/layouts/LineLayout.vue @@ -2,26 +2,20 @@ - - - - - {{ item.name }} - - - - + {{ projectName }} @@ -62,7 +56,7 @@ import { nextTick, } from 'vue'; import { useLineStore } from 'src/stores/line-store'; -import { usePslStore } from 'src/stores/psl-store.ts'; +import { usePslStore } from 'src/stores/psl-store'; import { useRoute, useRouter } from 'vue-router'; import { destroySimulation } from 'src/api/Simulation'; import StateProperties from 'src/components/line-app/StateProperties.vue'; @@ -90,6 +84,11 @@ const drawerRight = ref(false); const projectName = computed(() => projectInfo.name); +const sceneOptions = computed(() => { + return projectInfo.mapInfoLinks || []; +}); +const sceneInfo = ref(); + function onResize() { const clientWidth = document.documentElement.clientWidth; const clientHeight = document.documentElement.clientHeight; @@ -131,6 +130,7 @@ onMounted(async () => { return item.id == lineStore.mapId; }); if (find) { + sceneInfo.value = find; sceneName = getSceneNameFn(find); } lineStore.addAllScene(projectInfo.mapInfoLinks || []); @@ -197,22 +197,36 @@ watch( } ); function destroySimAndBack() { - if (simulationId) { - destroySimulation({ simulationId }); - } - backConfirm(); + $q.dialog({ + title: '确认', + message: `确认结束项目 "${projectName.value}" 吗?`, + cancel: true, + }).onOk(async () => { + try { + if (simulationId) { + await destroySimulation({ simulationId }); + } + backConfirm(); + } catch (err) { + const error = err as ApiError; + $q.notify({ + type: 'negative', + message: error.title, + }); + backConfirm(); + } + }); } function switchScene(val: MapInfo) { if (val.id == lineStore.mapId) return; - scene && scene.unbindDom(); lineStore.setMapId(val.id); sceneName = getSceneNameFn(val); lineStore.setSceneName(sceneName); - scene = lineApp.getScene(sceneName); const dom = document.getElementById('line-app-container'); if (dom) { - scene.bindDom(dom); + lineApp.switchScene(sceneName, dom); + scene = lineApp.getScene(sceneName); scene.reload(); } }