同步列车信息
This commit is contained in:
parent
3cf8850627
commit
566904cc5c
@ -274,7 +274,7 @@ export async function loadLineDatas(app: GraphicApp) {
|
|||||||
});
|
});
|
||||||
storage.allStatus.trainState.forEach((item) => {
|
storage.allStatus.trainState.forEach((item) => {
|
||||||
// 列车
|
// 列车
|
||||||
// states.push(new TrainState(item));
|
states.push(new TrainState(item));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
storage.varStatus.updatedSection.forEach((item) => {
|
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;
|
return states;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -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) {
|
function getTrainStates(train: Train) {
|
||||||
trainInfo.value = null;
|
trainInfo.value = null;
|
||||||
const s = train.states as ITrainState;
|
const s = train.states as ITrainState;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from 'pinia';
|
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';
|
import { initLineApp, getLineApp, destroyLineApp } from 'src/drawApp/lineApp';
|
||||||
|
|
||||||
export const useLineStore = defineStore('line', {
|
export const useLineStore = defineStore('line', {
|
||||||
@ -8,6 +8,7 @@ export const useLineStore = defineStore('line', {
|
|||||||
lineId: null as number | null,
|
lineId: null as number | null,
|
||||||
lineName: null as string | null,
|
lineName: null as string | null,
|
||||||
simulationId: null as string | null,
|
simulationId: null as string | null,
|
||||||
|
socketStates: null as GraphicState[] | null,
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
selectedGraphicType: (state) => {
|
selectedGraphicType: (state) => {
|
||||||
@ -50,5 +51,8 @@ export const useLineStore = defineStore('line', {
|
|||||||
setSimulationId(id: string | null) {
|
setSimulationId(id: string | null) {
|
||||||
this.simulationId = id;
|
this.simulationId = id;
|
||||||
},
|
},
|
||||||
|
setSocketStates(v: GraphicState[] | null) {
|
||||||
|
this.socketStates = v;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user