fix: mother board reactive problem
This commit is contained in:
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user