修改websocket状态消息处理查询方式

This commit is contained in:
walker 2023-07-06 11:21:49 +08:00
parent 1f302648b5
commit a7debf165e
3 changed files with 24 additions and 1 deletions

View File

@ -528,7 +528,10 @@ export class GraphicApp extends EventEmitter<GraphicAppEvents> {
*/
handleGraphicStates(graphicStates: GraphicState[]) {
graphicStates.forEach((state) => {
const list = this.queryStore.queryByIdOrCode(state.code);
const list = this.queryStore.queryByIdOrCodeAndType(
state.code,
state.graphicType
);
if (list.length == 0) {
const template = this.getGraphicTemplatesByType(state.graphicType);
const g = template.new();

View File

@ -37,6 +37,12 @@ export interface GraphicQueryStore {
* @param v
*/
queryByIdOrCode(v: string): JlGraphic[];
/**
* id或code及类型查询图形
* @param v
* @param type
*/
queryByIdOrCodeAndType(v: string, type: string): JlGraphic[];
/**
* code和类型获取图形
* @param code
@ -69,6 +75,7 @@ export class GraphicStore implements GraphicQueryStore {
this.store = new Map<string, JlGraphic>();
this.relationManage = new RelationManage(app);
}
/**
*
*/
@ -125,6 +132,15 @@ export class GraphicStore implements GraphicQueryStore {
});
return list;
}
queryByIdOrCodeAndType(s: string, type: string): JlGraphic[] {
const list: JlGraphic[] = [];
this.store.forEach((g) => {
if (g.isIdOrCode(s) && g.type === type) {
list.push(g);
}
});
return list;
}
queryByCodeAndType<T extends JlGraphic>(
code: string,
type: string

View File

@ -120,6 +120,7 @@
</template>
<script setup lang="ts">
import { Base64 } from 'js-base64';
import { useQuasar } from 'quasar';
import DrawProperties from 'src/components/draw-app/DrawProperties.vue';
import { getDrawApp, loadDrawDatas } from 'src/examples/app';
@ -157,6 +158,9 @@ function toggleFullscreen(e: unknown): void {
onMounted(() => {
console.log('绘制应用layout mounted');
const basic = Base64.decode('Zm9vOmJhcg==');
console.log(basic);
const dom = document.getElementById('draw-app-container');
if (dom) {
const drawApp = drawStore.initDrawApp(dom);