From 566904cc5c754f3cfdd4ac0393fc5f31a1f3e5c1 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 20 Jul 2023 16:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=97=E8=BD=A6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/lineApp.ts | 5 ++++- src/pages/TrainPage.vue | 16 ++++++++++++++++ src/stores/line-store.ts | 6 +++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index e1b1902..0150a7d 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -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; }, }); diff --git a/src/pages/TrainPage.vue b/src/pages/TrainPage.vue index d25484d..5cf9816 100644 --- a/src/pages/TrainPage.vue +++ b/src/pages/TrainPage.vue @@ -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; diff --git a/src/stores/line-store.ts b/src/stores/line-store.ts index df99e79..4b2f2e6 100644 --- a/src/stores/line-store.ts +++ b/src/stores/line-store.ts @@ -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; + }, }, });