Browse Source

fix:除湿自动停止

master
guoapeng 5 months ago
parent
commit
a7235ba15d
  1. 4
      src/stores/useSystemStore.ts
  2. 11
      src/views/main/index.vue
  3. 1
      src/views/spraySet/index.vue

4
src/stores/useSystemStore.ts

@ -19,8 +19,12 @@ export const useSystemStore = defineStore('system', {
isDebug: false,
streamVisible: false,
systemList: [{ cmdCode: '' }],
targetHumidity: 0,
}),
actions: {
updateTargetHumidity(humidity: number) {
this.targetHumidity = humidity
},
updateSystemStatus(status: any) {
this.systemStatus = status
},

11
src/views/main/index.vue

@ -4,6 +4,7 @@ import FtStream from 'components/common/FTStream/index.vue'
import Check from 'components/home/Check/index.vue'
import Stop from 'components/home/stop/index.vue'
import { ElMessageBox } from 'element-plus'
import { FtMessage } from 'libs/message'
import { isClose, socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { useSystemStore } from 'stores/useSystemStore' // systemStore
@ -50,9 +51,17 @@ const statusMessage = (data: any) => {
systemStore.updateSystemStatus(data)
}
const sensorMessage = (data: any) => {
const sensorMessage = async (data: any) => {
// systemStore systemInfo
systemStore.updateSystemSensor(data)
if (systemStore.systemStatus.dehumidifierRunning && systemStore.systemSensor.humidity <= systemStore.targetHumidity) {
const params = {
cmdCode: 'dehumidifier_stop',
cmdId: '',
}
await sendControl(params)
FtMessage.success('当前湿度已达目标湿度,除湿已完成')
}
}
socket.init(statusMessage, 'device_status_change')

1
src/views/spraySet/index.vue

@ -65,6 +65,7 @@ const dehumidifierStart = () => {
},
}
await sendControl(params)
systemStore.updateTargetHumidity(humidity.value)
dehumidifierStartRef.value.setLoading(false)
})
.catch(() => {

Loading…
Cancel
Save