From 599e6b2abd863c5784f23bc1699f4940af386fa3 Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Tue, 15 Aug 2023 11:32:07 +0800 Subject: [PATCH] some times --- src/components/Progress.vue | 12 +++++++++--- src/pages/Home.vue | 2 +- src/store/modules/setting.js | 4 ++++ src/store/modules/websocket.js | 9 +++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/Progress.vue b/src/components/Progress.vue index 761b7b9..0fc97a3 100644 --- a/src/components/Progress.vue +++ b/src/components/Progress.vue @@ -3,7 +3,7 @@
剩余时间
-

{{ operatorStore.estimatedRemainingTimeS }}

+

{{ operatorStore.estimatedRemainingTimeS }} S

import { useOperatorStore, useWebSocketStore } from '@/store' import { stopDisinfectionJSON, getStateJSON } from '@/mock/command' -import { onMounted } from 'vue' +import { onMounted, onUnmounted, ref } from 'vue' const operatorStore = useOperatorStore() const webSocketStore = useWebSocketStore() @@ -64,8 +64,14 @@ const showDetail = () => { props.changeShowOperator(true) } +const timer = ref(null) onMounted(() => { - webSocketStore.sendCommandMsg(getStateJSON) + timer.value = setInterval(() => { + webSocketStore.sendCommandMsg(getStateJSON) + }, 1000) +}) +onUnmounted(() => { + timer.value = null }) const pauseDisinfect = () => { diff --git a/src/pages/Home.vue b/src/pages/Home.vue index 837999b..b839578 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -133,7 +133,7 @@
-

IP192.0.0.0.0

+

IP {{ settingStore.deviceIp }}

{{ nowTime }}

diff --git a/src/store/modules/setting.js b/src/store/modules/setting.js index 2d4156b..9ae5e05 100644 --- a/src/store/modules/setting.js +++ b/src/store/modules/setting.js @@ -21,10 +21,14 @@ export const useSettingStore = defineStore({ initLoading: true, // 所有setting的对象数据 allSettingList: [], + deviceIp: '127.0.0.1', } }, // actions actions: { + updateDeviceIp(deviceIp) { + this.deviceIp = deviceIp + }, updateMaxHumidity(max_humidity) { this.max_humidity = max_humidity }, diff --git a/src/store/modules/websocket.js b/src/store/modules/websocket.js index a732f77..7de2c3a 100644 --- a/src/store/modules/websocket.js +++ b/src/store/modules/websocket.js @@ -4,6 +4,7 @@ import { useSettingStore } from './setting' import { useUserStore } from './user' import { useOperatorStore } from './operator' import { useDeviceStore } from './device' +import { useTestStore } from './test' export const useWebSocketStore = defineStore({ id: 'websocket', // id必填,且需要唯一 @@ -83,6 +84,8 @@ export const useWebSocketStore = defineStore({ const init = new Socket(url) init.connect() const deviceStore = useDeviceStore() + const testStore = useTestStore() + const settingStore = useSettingStore() init.ws.onmessage = function (ev) { console.log(JSON.parse(ev.data)) const { command } = JSON.parse(ev.data) @@ -99,8 +102,14 @@ export const useWebSocketStore = defineStore({ temp_1, temp_2, temp_3, + air_compressor, + disinfectant_volume, + heating_strip, + sprinkler_pump, } = sensor_data // 将sensor_data中的数据更新到store中 + settingStore.updateDeviceIp('127.0.0.1') + deviceStore.updateDisinfectantCapacity(disinfectant_volume) deviceStore.updateBinTemperature(temp_1) deviceStore.updateBinHumidity(humid_1) deviceStore.updateBinHP(h2o2_1)