From 9116a5758eeb80ea9ea8a0d241c6b908f0fab208 Mon Sep 17 00:00:00 2001 From: AkiChase <1003019131@qq.com> Date: Fri, 31 May 2024 18:44:16 +0800 Subject: [PATCH] fix(KeySwipe): performance --- src/components/keyboard/KeyBoard.vue | 2 +- src/components/keyboard/KeySwipe.vue | 1 + src/hotkey.ts | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/keyboard/KeyBoard.vue b/src/components/keyboard/KeyBoard.vue index d592fc7..3180497 100644 --- a/src/components/keyboard/KeyBoard.vue +++ b/src/components/keyboard/KeyBoard.vue @@ -104,7 +104,7 @@ function onAddButtonSelect( (keyMapping as KeyMappingKeySwipe).pos = [ { x: keyMapping.posX, y: keyMapping.posY }, ]; - (keyMapping as KeyMappingKeySwipe).intervalBetweenPos = 0; + (keyMapping as KeyMappingKeySwipe).intervalBetweenPos = 100; } else if (type === "SteeringWheel") { keyMapping.pointerId = 1; (keyMapping as unknown as KeyMappingSteeringWheel).key = { diff --git a/src/components/keyboard/KeySwipe.vue b/src/components/keyboard/KeySwipe.vue index 5389259..cab752a 100644 --- a/src/components/keyboard/KeySwipe.vue +++ b/src/components/keyboard/KeySwipe.vue @@ -102,6 +102,7 @@ function editSwipePoints() { message.info(t("pages.KeyBoard.Swipe.editTips")); keyboardStore.showButtonSettingFlag = false; keyboardStore.editSwipePointsFlag = true; + keyboardStore.edited = true; } function swipePointDragHandlue(downEvent: MouseEvent, index: number) { diff --git a/src/hotkey.ts b/src/hotkey.ts index 511f41d..9c8c580 100644 --- a/src/hotkey.ts +++ b/src/hotkey.ts @@ -957,10 +957,13 @@ function addSwipeShortcuts( pointerId: number, intervalBetweenPos: number ) { - for (const posObj of pos) { - posObj.x = Math.round((posObj.x / relativeSize.w) * store.screenSizeW); - posObj.y = Math.round((posObj.y / relativeSize.h) * store.screenSizeH); - } + const newPosList = pos.map((posObj) => { + return { + x: Math.round((posObj.x / relativeSize.w) * store.screenSizeW), + y: Math.round((posObj.y / relativeSize.h) * store.screenSizeH), + }; + }); + addShortcut( key, async () => { @@ -971,7 +974,7 @@ function addSwipeShortcuts( w: store.screenSizeW, h: store.screenSizeH, }, - pos, + pos: newPosList, intervalBetweenPos, }); },