import {inject, reactive} from "vue"; import {useMachineStore} from "@/store/useMachineStore"; export const machineFun = { machine: reactive({ scan: false, bmi: false, }), notifyMachineUsb({id, up}) { console.log('notifyMachineUsb', id, up) const machineStore = useMachineStore() this.machine[id] = up machineStore.setStatus(id, up) }, getOnlineUsb(machine, callback) { let list = machine.getOnlineUsb() if (list) { list.forEach(it => { this.notifyMachineUsb({ id: it, up: true, }) }) } if (callback) callback() }, setUsbNotify(open = true) { if (open) { uni.$on('machineUsb', this.notifyMachineUsb) } else { uni.$off('machineUsb', this.notifyMachineUsb) } }, }