Squashed commit of the following:
All checks were successful
CI / Docker-Build (push) Successful in 1m54s

commit 89012e6290
Author: joylink_zhaoerwei <Bob_Engineer@163.com>
Date:   Thu May 9 16:08:02 2024 +0800

    列车驾驶台方向按钮操作失败会回到之前的位置
This commit is contained in:
joylink_zhaoerwei 2024-05-09 16:34:22 +08:00
parent 60ca381302
commit 9e8abf4624
2 changed files with 11 additions and 7 deletions

View File

@ -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();
}

View File

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