From 89012e62906f01af3f9e9071b5f8bab5cae4fa99 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 9 May 2024 16:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E9=A9=BE=E9=A9=B6=E5=8F=B0?= =?UTF-8?q?=E6=96=B9=E5=90=91=E6=8C=89=E9=92=AE=E6=93=8D=E4=BD=9C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=BC=9A=E5=9B=9E=E5=88=B0=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/graphics/TccKeyInteraction.ts | 6 ++---- src/stores/tcc-store.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/drawApp/graphics/TccKeyInteraction.ts b/src/drawApp/graphics/TccKeyInteraction.ts index df0f6c5..d8477c6 100644 --- a/src/drawApp/graphics/TccKeyInteraction.ts +++ b/src/drawApp/graphics/TccKeyInteraction.ts @@ -107,7 +107,6 @@ export abstract class KeyInteraction< mouseDownBeginRotation = 0; changeRotation = 0; keyInteractionConfig: IKeyInteractionConfig; - lastTimenRotation = 0; constructor( name: string, app: IGraphicScene, @@ -155,7 +154,7 @@ export abstract class KeyInteraction< this.mouseDownBeginPos = this.app.toCanvasCoordinates(e.global); this.mouseDownBeginRotation = this.ratatingSprite.rotation; this.changeRotation = this.mouseDownBeginRotation; - this.lastTimenRotation = this.ratatingSprite.rotation; + useTccStore().tccKeyLastRotation = this.ratatingSprite.rotation; } onMousemove(e: FederatedMouseEvent) { const target = e.target as DisplayObject; @@ -204,8 +203,7 @@ export abstract class KeyInteraction< this.changeRotation = this.mouseDownBeginRotation - Math.PI / 2; } } - if (this.lastTimenRotation !== this.changeRotation) { - this.lastTimenRotation = this.changeRotation; + if (this.ratatingSprite.rotation !== this.changeRotation) { this.ratatingSprite.rotation = this.changeRotation; useTccStore().onMouseUpFromTccKeyDir(); } diff --git a/src/stores/tcc-store.ts b/src/stores/tcc-store.ts index 1357e6b..a107219 100644 --- a/src/stores/tcc-store.ts +++ b/src/stores/tcc-store.ts @@ -19,6 +19,7 @@ export const useTccStore = defineStore('tcc', { tccHandleId: 0, mouseDownOnTccKeyDir: false, tccKeyDirId: 0, + tccKeyLastRotation: 0, }), actions: { getTccScene() { @@ -84,9 +85,14 @@ export const useTccStore = defineStore('tcc', { dirKey: { val: position, }, - }).catch((err) => { - errorNotify('操作失败', { message: err.origin.response.data.title }); - }); + }) + .then(() => { + this.tccKeyLastRotation = tccKeyDir._tccKey.rotation; + }) + .catch((err) => { + errorNotify('操作失败', { message: err.origin.response.data.title }); + tccKeyDir._tccKey.rotation = this.tccKeyLastRotation; + }); }, }, });