fix: matrix key not work

This commit is contained in:
SikongJueluo 2025-05-20 17:23:00 +08:00
parent bea1c7e5ae
commit e4791b41a8
No known key found for this signature in database
1 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { ref, watchEffect, watchPostEffect } from 'vue' import { ref, reactive, watchPostEffect } from 'vue'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { isString, toNumber, isUndefined } from 'lodash'; import { isString, toNumber } from 'lodash';
import { Common } from '@/Common'; import { Common } from '@/Common';
import z from "zod" import z from "zod"
import { isNumber } from 'mathjs'; import { isNumber } from 'mathjs';
@ -25,7 +25,7 @@ export const useEquipments = defineStore('equipments', () => {
const jtagClient = new JtagClient(); const jtagClient = new JtagClient();
// Matrix Key // Matrix Key
const matrixKeyStates = ref(new Array<boolean>(16).fill(false)) const matrixKeyStates = reactive(new Array<boolean>(16).fill(false))
const matrixKeypadClientMutex = withTimeout(new Mutex(), 1000, new Error("Matrixkeyclient Mutex Timeout!")); const matrixKeypadClientMutex = withTimeout(new Mutex(), 1000, new Error("Matrixkeyclient Mutex Timeout!"));
const matrixKeypadClient = new MatrixKeyClient(); const matrixKeypadClient = new MatrixKeyClient();
@ -40,7 +40,7 @@ export const useEquipments = defineStore('equipments', () => {
watchPostEffect(async () => { watchPostEffect(async () => {
if (true === enableMatrixKey.value) { if (true === enableMatrixKey.value) {
const ret = await matrixKeypadSetKeyStates(matrixKeyStates.value) const ret = await matrixKeypadSetKeyStates(matrixKeyStates)
if (!ret) { if (!ret) {
dialog.error("设置矩阵键盘失败") dialog.error("设置矩阵键盘失败")
enableMatrixKey.value = false; enableMatrixKey.value = false;
@ -87,7 +87,7 @@ export const useEquipments = defineStore('equipments', () => {
} }
if (z.number().nonnegative().max(16).safeParse(_keyNum).success) { if (z.number().nonnegative().max(16).safeParse(_keyNum).success) {
matrixKeyStates.value[_keyNum] = keyValue; matrixKeyStates[_keyNum] = keyValue;
return true; return true;
} }
return false; return false;
@ -184,7 +184,7 @@ export const useEquipments = defineStore('equipments', () => {
const resp = await matrixKeypadClient.setMatrixKeyStatus( const resp = await matrixKeypadClient.setMatrixKeyStatus(
boardAddr.value, boardAddr.value,
boardPort.value, boardPort.value,
matrixKeyStates.value matrixKeyStates
); );
return resp; return resp;
} catch (e) { } catch (e) {