diff --git a/src/stores/tcc-store.ts b/src/stores/tcc-store.ts index 77dad4b..1357e6b 100644 --- a/src/stores/tcc-store.ts +++ b/src/stores/tcc-store.ts @@ -7,6 +7,7 @@ import { errorNotify } from 'src/utils/CommonNotify'; import { request } from 'src/protos/request'; import { TccHandle } from 'src/graphics/tccHandle/TccHandle'; import { TccKey } from 'src/graphics/tccKey/TccKey'; +import { IGraphicApp } from 'jl-graphic'; export const useTccStore = defineStore('tcc', { state: () => ({ @@ -23,12 +24,8 @@ export const useTccStore = defineStore('tcc', { getTccScene() { const lineApp = getLineApp(); if (!lineApp) throw Error('未初始化app'); - try { - return lineApp.getScene('tcc'); - } catch (error) { - const tccScene = initTccScene(lineApp, 'tcc'); - return tccScene; - } + lineApp.removeScene('tcc'); + return initTccScene(lineApp, 'tcc'); }, setTccParam(tccId: number, trainControlMapId: number) { this.tccId = tccId; @@ -42,9 +39,9 @@ export const useTccStore = defineStore('tcc', { }, onMouseUpFromTccHandle() { const simulationId = useLineStore().simulationId; - const tccHandle = this.getTccScene().queryStore.queryById( - this.tccHandleId - ); + const tccHandle = (getLineApp() as IGraphicApp) + .getScene('tcc') + .queryStore.queryById(this.tccHandleId); if (!simulationId) return; const handleVal = Number( (-(tccHandle._tccHandle.y / 144) * 100).toFixed() @@ -62,9 +59,9 @@ export const useTccStore = defineStore('tcc', { }); }, onMouseUpFromTccKeyDir() { - const tccKeyDir = this.getTccScene().queryStore.queryById( - this.tccKeyDirId - ); + const tccKeyDir = (getLineApp() as IGraphicApp) + .getScene('tcc') + .queryStore.queryById(this.tccKeyDirId); let position = 0; switch (tccKeyDir._tccKey.rotation) { case Math.PI / 4: