fix: mother board reactive problem

This commit is contained in:
2025-05-16 16:38:57 +08:00
parent 1eded97c76
commit c39f688115
11 changed files with 1063 additions and 464 deletions

View File

@@ -1,21 +1,37 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { isUndefined } from 'lodash';
import { isString, isUndefined, toNumber } from 'lodash';
import z from "zod"
import { isNumber } from 'mathjs';
export const useEquipments = defineStore('equipments', () => {
const jtagIPAddr = ref("127.0.0.1")
const jtagPort = ref("1234")
const boardAddr = ref("127.0.0.1")
const boardPort = ref(1234)
function setAddr(address: string) {
if (z.string().ip("4").safeParse(address).success)
boardAddr.value = address;
}
function setPort(port: string | number) {
if (isString(port) && port.length != 0) {
const portNumber = toNumber(port);
if (z.number().nonnegative().max(65535).safeParse(portNumber).success)
boardPort.value = portNumber;
}
else if (isNumber(port)) {
if (z.number().nonnegative().max(65535).safeParse(port).success)
boardPort.value = port;
}
}
const jtagBitstream = ref<File | undefined>()
const remoteUpdateIPAddr = ref("127.0.0.1")
const remoteUpdatePort = ref("1234")
const remoteUpdateBitstream = ref<File | undefined>()
return {
jtagIPAddr,
jtagPort,
boardAddr,
boardPort,
setAddr,
setPort,
jtagBitstream,
remoteUpdateIPAddr,
remoteUpdatePort,
remoteUpdateBitstream,
}
})