import { ref, computed } from 'vue'
|
import { defineStore } from 'pinia'
|
import type { Devices } from '@/api/device'
|
import { getDeviceList } from '@/api'
|
|
export const useDevicesStore = defineStore('counter', () => {
|
const devices = ref<Devices>()
|
const deviceIDList = computed(() => devices?.value?.deviceIDList ?? [])
|
|
function getDevicesInfo() {
|
getDeviceList().then(
|
(res) => {
|
devices.value = res?.data
|
},
|
(err) => {
|
console.error(err)
|
devices.value = undefined
|
}
|
)
|
}
|
|
return { devices, deviceIDList, getDevicesInfo }
|
})
|