import { sendCmd } from 'apis/system' import { defineStore } from 'pinia' import { ref } from 'vue' /** * 主页数据管理模块 * @module useHomeStore */ interface gasPathSwitcher { gasPathSwitcher: gasPathSwitcher path: string } interface gasPathSwitcher { isOnline: boolean } export const useGasStore = defineStore('gas', () => { // 状态定义 const channelSwitcherMap = ['degradation', 'disinfection', 'dehumidification'] const isOnline = ref(false) const currentChannel = ref(null) /** * 选择通道 */ const selectChannel = async (data: string) => { const defaultParams = { className: 'DMGasPathMgrService', fnName: 'selectChannel', params: { dmGasPath: data, }, } return await sendCmd(defaultParams) } /** * 根据上报的数据更新当前通道和线上状态 */ const updateChannelByReport = (data: gasPathSwitcher) => { isOnline.value = data.gasPathSwitcher.isOnline currentChannel.value = data.path } return { channelSwitcherMap, currentChannel, isOnline, selectChannel, updateChannelByReport, } })