保留app
This commit is contained in:
parent
0ecd9aac7c
commit
b00010901a
@ -77,21 +77,25 @@ import { useUserStore } from 'src/stores/user-store';
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
|
||||
let lineApp: IGraphicApp | null = null;
|
||||
const lineAppMap = new Map<number, IGraphicApp>();
|
||||
|
||||
export function getLineApp() {
|
||||
return lineApp;
|
||||
}
|
||||
|
||||
export function destroyLineApp(): void {
|
||||
if (lineApp) {
|
||||
lineApp.destroy();
|
||||
lineApp = null;
|
||||
for (const key of lineAppMap.keys()) {
|
||||
const app = lineAppMap.get(key);
|
||||
if (app) {
|
||||
app.destroy();
|
||||
}
|
||||
}
|
||||
lineApp = null;
|
||||
}
|
||||
|
||||
export function initLineApp(): IGraphicApp {
|
||||
export function initLineApp(lineId: number): IGraphicApp {
|
||||
lineApp = lineAppMap.get(lineId) || null;
|
||||
if (lineApp) return lineApp;
|
||||
|
||||
lineApp = newGraphicApp({
|
||||
interactiveGraphicTypeIncludes: [
|
||||
Signal.Type,
|
||||
@ -109,6 +113,7 @@ export function initLineApp(): IGraphicApp {
|
||||
},
|
||||
dataLoader: loadLineDatas,
|
||||
});
|
||||
lineAppMap.set(lineId, lineApp);
|
||||
|
||||
const graphicTemplate = [
|
||||
new TrainTemplate(new TrainData(), new TrainState()),
|
||||
|
@ -52,6 +52,7 @@ export function destroyLineNetApp(): void {
|
||||
}
|
||||
|
||||
export function initLineNetApp(): IGraphicApp {
|
||||
if (lineNetApp) return lineNetApp;
|
||||
lineNetApp = newGraphicApp({
|
||||
interactiveGraphicTypeIncludes: [
|
||||
RunLine.Type,
|
||||
|
@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, watch, onUnmounted } from 'vue';
|
||||
import { onMounted, watch } from 'vue';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useLineNetStore } from 'src/stores/line-net-store';
|
||||
@ -80,7 +80,7 @@ function centerFaultDevice() {
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
lineStore.destroy();
|
||||
});
|
||||
// onUnmounted(() => {
|
||||
// lineStore.destroy();
|
||||
// });
|
||||
</script>
|
||||
|
@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, watch, onUnmounted } from 'vue';
|
||||
import { onMounted, watch } from 'vue';
|
||||
import { useLineNetStore } from 'src/stores/line-net-store';
|
||||
import { RunLine } from 'src/graphics/runLine/RunLine';
|
||||
import { useRouter } from 'vue-router';
|
||||
@ -73,7 +73,7 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
lineNetStore.destroy();
|
||||
});
|
||||
// onUnmounted(() => {
|
||||
// lineNetStore.destroy();
|
||||
// });
|
||||
</script>
|
||||
|
@ -39,7 +39,7 @@ export const useLineStore = defineStore('line', {
|
||||
},
|
||||
initLineApp(lineId: number) {
|
||||
this.setLineId(lineId);
|
||||
const app = initLineApp();
|
||||
const app = initLineApp(lineId);
|
||||
app.on('graphicselected', (graphics) => {
|
||||
this.selectedGraphics = markRaw(graphics);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user