fix: matrix key not work
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
import { ref, watchEffect, watchPostEffect } from 'vue'
 | 
			
		||||
import { ref, reactive, watchPostEffect } from 'vue'
 | 
			
		||||
import { defineStore } from 'pinia'
 | 
			
		||||
import { isString, toNumber, isUndefined } from 'lodash';
 | 
			
		||||
import { isString, toNumber } from 'lodash';
 | 
			
		||||
import { Common } from '@/Common';
 | 
			
		||||
import z from "zod"
 | 
			
		||||
import { isNumber } from 'mathjs';
 | 
			
		||||
@@ -25,7 +25,7 @@ export const useEquipments = defineStore('equipments', () => {
 | 
			
		||||
  const jtagClient = new JtagClient();
 | 
			
		||||
 | 
			
		||||
  // 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 matrixKeypadClient = new MatrixKeyClient();
 | 
			
		||||
 | 
			
		||||
@@ -40,7 +40,7 @@ export const useEquipments = defineStore('equipments', () => {
 | 
			
		||||
 | 
			
		||||
  watchPostEffect(async () => {
 | 
			
		||||
    if (true === enableMatrixKey.value) {
 | 
			
		||||
      const ret = await matrixKeypadSetKeyStates(matrixKeyStates.value)
 | 
			
		||||
      const ret = await matrixKeypadSetKeyStates(matrixKeyStates)
 | 
			
		||||
      if (!ret) {
 | 
			
		||||
        dialog.error("设置矩阵键盘失败")
 | 
			
		||||
        enableMatrixKey.value = false;
 | 
			
		||||
@@ -87,7 +87,7 @@ export const useEquipments = defineStore('equipments', () => {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (z.number().nonnegative().max(16).safeParse(_keyNum).success) {
 | 
			
		||||
      matrixKeyStates.value[_keyNum] = keyValue;
 | 
			
		||||
      matrixKeyStates[_keyNum] = keyValue;
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
@@ -184,7 +184,7 @@ export const useEquipments = defineStore('equipments', () => {
 | 
			
		||||
      const resp = await matrixKeypadClient.setMatrixKeyStatus(
 | 
			
		||||
        boardAddr.value,
 | 
			
		||||
        boardPort.value,
 | 
			
		||||
        matrixKeyStates.value
 | 
			
		||||
        matrixKeyStates
 | 
			
		||||
      );
 | 
			
		||||
      return resp;
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user