This commit is contained in:
fan 2023-07-20 16:57:08 +08:00
commit 9407e855e9
3 changed files with 25 additions and 2 deletions

View File

@ -274,7 +274,7 @@ export async function loadLineDatas(app: GraphicApp) {
});
storage.allStatus.trainState.forEach((item) => {
// 列车
// states.push(new TrainState(item));
states.push(new TrainState(item));
});
} else {
storage.varStatus.updatedSection.forEach((item) => {
@ -305,6 +305,9 @@ export async function loadLineDatas(app: GraphicApp) {
}
});
}
if (states && states.length > 0) {
lineStore.setSocketStates(states);
}
return states;
},
});

View File

@ -94,6 +94,22 @@ watch(
}
}
);
watch(
() => lineStore.socketStates,
(val) => {
if (val && trainInfo.value) {
const find = val.find((item) => {
return (
item.graphicType == Train.Type &&
(item as ITrainState).id == trainInfo.value?.id
);
});
if (find) {
trainInfo.value.copyFrom(find);
}
}
}
);
function getTrainStates(train: Train) {
trainInfo.value = null;
const s = train.states as ITrainState;

View File

@ -1,5 +1,5 @@
import { defineStore } from 'pinia';
import { JlCanvas, JlGraphic, GraphicApp } from 'src/jl-graphic';
import { JlCanvas, JlGraphic, GraphicApp, GraphicState } from 'src/jl-graphic';
import { initLineApp, getLineApp, destroyLineApp } from 'src/drawApp/lineApp';
export const useLineStore = defineStore('line', {
@ -8,6 +8,7 @@ export const useLineStore = defineStore('line', {
lineId: null as number | null,
lineName: null as string | null,
simulationId: null as string | null,
socketStates: null as GraphicState[] | null,
}),
getters: {
selectedGraphicType: (state) => {
@ -50,5 +51,8 @@ export const useLineStore = defineStore('line', {
setSimulationId(id: string | null) {
this.simulationId = id;
},
setSocketStates(v: GraphicState[] | null) {
this.socketStates = v;
},
},
});