|
|
import { defineStore } from 'pinia' import { ref } from 'vue'
import { sendCmd } from '@/apis/system'
export const useSystemStore = defineStore('system', () => { const websocketConnected = ref(true) const systemUser = ref({ username: '', })
const loginForm = ref({ name: import.meta.env.FT_NODE_ENV !== 'prod' ? 'admin' : '', pwd: import.meta.env.FT_NODE_ENV !== 'prod' ? '123' : '', })
const languages = [ { name: '中文', value: 'zh-cn', }, // {
// name: 'English',
// value: 'en',
// },
]
const menuExpand = true const isDebug = import.meta.env.FT_NODE_ENV !== 'prod' const streamVisible = false const systemList = ref([]) const loading = ref(false) const systemTime = ref(Date.now())
const updateLoading = (loadVal: boolean) => { loading.value = loadVal // setTimeout(() => {
// loading.value = false
// }, 1500)
}
const updateConnected = (isConnected: boolean) => { websocketConnected.value = isConnected }
/** * @function subscribeDisinfectEvent * @desc 订阅消毒状态变更事件 */ // const subscribeDisinfectEvent = async () => {
// // 发起订阅
// const subParams = {
// className: 'DisinfectionCtrlServiceExt',
// fnName: 'startStateReport',
// }
// syncSendCmd(subParams)
// }
/** * @function subscribeAddLiquidEvent * @desc 加液状态变更事件 */ // const subscribeAddLiquidEvent = async () => {
// // 发起订阅
// const subParams = {
// className: 'AddLiquidService',
// fnName: 'startStateReport',
// }
// syncSendCmd(subParams)
// }
/** * @function subscribeDrainLiquidEvent * @desc 排液状态变更事件 */ // const subscribeDrainLiquidEvent = async () => {
// // 发起订阅
// const subParams = {
// className: 'DrainLiquidService',
// fnName: 'startStateReport',
// }
// syncSendCmd(subParams)
// }
const getSystemTime = async () => { const timeParams = { className: 'OsMgrService', fnName: 'getTime', } const res = await sendCmd(timeParams) systemTime.value = res.time }
return { systemUser, loginForm, languages, menuExpand, isDebug, streamVisible, systemList, loading, websocketConnected, systemTime,
updateLoading, updateConnected, getSystemTime, } })
|