From 4465091db324536a2a5f9ba3ebd6e25aa511cf79 Mon Sep 17 00:00:00 2001 From: alivender <13898766233@163.com> Date: Fri, 25 Apr 2025 13:20:04 +0800 Subject: [PATCH] feat: remake machanicalbutton --- .../equipments/MechanicalButton.vue | 137 +++++++++--------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/src/components/equipments/MechanicalButton.vue b/src/components/equipments/MechanicalButton.vue index 125be3b..c04d2e5 100644 --- a/src/components/equipments/MechanicalButton.vue +++ b/src/components/equipments/MechanicalButton.vue @@ -1,37 +1,52 @@ @@ -65,29 +83,28 @@ interface Props { width?: string | number height?: string | number } -const bindKey = ref(''); -let isKeyPressed = false; + const props = withDefaults(defineProps(), { width: 160, height: 160, }) -const btnHeight = ref(200) - -const colorMatrix = ref("1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0") - -function toggleButtonState(isPressed: boolean) { - btnHeight.value = isPressed ? 210 : 200; - colorMatrix.value = isPressed - ? "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.7 0" - : "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"; -} - +const bindKey = ref(''); +let isKeyPressed = false; +const btnHeight = ref(200); +const colorMatrix = ref("1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"); const isBinding = ref(false); const showContextMenu = ref(false); const contextMenuX = ref(0); const contextMenuY = ref(0); +function toggleButtonState(isPressed: boolean) { + btnHeight.value = isPressed ? 210 : 200; + colorMatrix.value = isPressed + ? "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.7 0" + : "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"; +} + function openContextMenu(e: MouseEvent) { contextMenuX.value = e.clientX; contextMenuY.value = e.clientY; @@ -135,21 +152,3 @@ onUnmounted(() => { window.removeEventListener('click', closeContextMenu); }); - -