Browse Source

some times

master
maochaoying 2 years ago
parent
commit
599e6b2abd
  1. 12
      src/components/Progress.vue
  2. 2
      src/pages/Home.vue
  3. 4
      src/store/modules/setting.js
  4. 9
      src/store/modules/websocket.js

12
src/components/Progress.vue

@ -3,7 +3,7 @@
<div class="header_wrap">
<div class="left_progress">
<div class="left_time_tag">剩余时间</div>
<p class="time">{{ operatorStore.estimatedRemainingTimeS }}</p>
<p class="time">{{ operatorStore.estimatedRemainingTimeS }} S</p>
<div class="progress_bg">
<div
class="pro"
@ -51,7 +51,7 @@
<script setup>
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 = () => {

2
src/pages/Home.vue

@ -133,7 +133,7 @@
<Test v-if="activeTab == 4" />
<Setting v-if="activeTab == 5" />
<div class="other_info">
<p>IP192.0.0.0.0</p>
<p>IP {{ settingStore.deviceIp }}</p>
<p class="time">{{ nowTime }}</p>
</div>
<div class="log_out_btn" @click="handleLogout">

4
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
},

9
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)

Loading…
Cancel
Save