diff --git a/src/stores/useSystemStore.ts b/src/stores/useSystemStore.ts index 503205e..51d0c69 100644 --- a/src/stores/useSystemStore.ts +++ b/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 }, diff --git a/src/views/main/index.vue b/src/views/main/index.vue index 9a66d9f..903bec1 100644 --- a/src/views/main/index.vue +++ b/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') diff --git a/src/views/spraySet/index.vue b/src/views/spraySet/index.vue index 058dd2d..4506324 100644 --- a/src/views/spraySet/index.vue +++ b/src/views/spraySet/index.vue @@ -65,6 +65,7 @@ const dehumidifierStart = () => { }, } await sendControl(params) + systemStore.updateTargetHumidity(humidity.value) dehumidifierStartRef.value.setLoading(false) }) .catch(() => {