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; + }); }, }, });