切换列车驾驶台重新加载(订阅路径变)

This commit is contained in:
joylink_zhaoerwei 2024-05-07 15:12:28 +08:00
parent a337216236
commit 2e3fc1a1f2

View File

@ -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<TccHandle>(
this.tccHandleId
);
const tccHandle = (getLineApp() as IGraphicApp)
.getScene('tcc')
.queryStore.queryById<TccHandle>(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<TccKey>(
this.tccKeyDirId
);
const tccKeyDir = (getLineApp() as IGraphicApp)
.getScene('tcc')
.queryStore.queryById<TccKey>(this.tccKeyDirId);
let position = 0;
switch (tccKeyDir._tccKey.rotation) {
case Math.PI / 4: