From a7235ba15dee7e38b118a9413fb355b3bcb746ba Mon Sep 17 00:00:00 2001 From: guoapeng Date: Fri, 21 Mar 2025 07:06:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=99=A4=E6=B9=BF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=81=9C=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/useSystemStore.ts | 4 ++++ src/views/main/index.vue | 11 ++++++++++- src/views/spraySet/index.vue | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) 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(() => {