From 34c9255f43fa7a9b1cce94c62dd6855e98fafcfa Mon Sep 17 00:00:00 2001 From: walker Date: Thu, 13 Jul 2023 17:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E5=9B=BE=E5=BD=A2=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B6=88=E6=81=AF=E5=90=8E=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=80=BB=E8=BE=91=EF=BC=9A=E5=85=88=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C=E5=86=8D=E7=BB=9F=E4=B8=80=E9=87=8D?= =?UTF-8?q?=E7=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jlgraphic/app/JlGraphicApp.ts | 11 ++++++++--- src/jlgraphic/core/JlGraphic.ts | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/jlgraphic/app/JlGraphicApp.ts b/src/jlgraphic/app/JlGraphicApp.ts index 5cf08f3..c581ad3 100644 --- a/src/jlgraphic/app/JlGraphicApp.ts +++ b/src/jlgraphic/app/JlGraphicApp.ts @@ -543,9 +543,14 @@ export class GraphicApp extends EventEmitter { g.loadState(state); this.addGraphics(g); } else { - list.forEach((g) => { - g.updateStates(state); - }); + // 调整逻辑:所有图形对象状态数据更新完后再统一重绘 + list + .filter((g) => { + return g.updateStates(state); + }) + .forEach((g) => { + g.repaint(); + }); } }); } diff --git a/src/jlgraphic/core/JlGraphic.ts b/src/jlgraphic/core/JlGraphic.ts index 7ed967a..a350a8c 100644 --- a/src/jlgraphic/core/JlGraphic.ts +++ b/src/jlgraphic/core/JlGraphic.ts @@ -902,7 +902,7 @@ export abstract class JlGraphic extends Container { this.onStateChange(state, old); stateChange = true; this.emit('stateupdate', this.getStates(), old); - this.repaint(); + // this.repaint(); } return stateChange; } @@ -912,8 +912,12 @@ export abstract class JlGraphic extends Container { onStateChange(newVal: GraphicState, old?: GraphicState): void {} repaint(): void { - this.doRepaint(); - this.emit('repaint', this); + try { + this.doRepaint(); + this.emit('repaint', this); + } catch (e) { + console.error(`设备id=${this.id},type=${this.type}重绘逻辑异常`, e); + } } /**