Ver código fonte

feat: 调整设备点位超时时间为1秒;

liujia 2 meses atrás
pai
commit
29972853ae
2 arquivos alterados com 10 adições e 8 exclusões
  1. 9 7
      src/layout/index.vue
  2. 1 1
      src/views/device/detail/index.vue

+ 9 - 7
src/layout/index.vue

@@ -84,15 +84,17 @@ const version = __APP_VERSION__
 // const buildTime = __BUILD_TIME__
 
 let mqttClient: MqttClient | null = null
-let mqttTimeout: number | null = null
-const MQTT_TIMEOUT_MS = 10000 // 10秒
+// let mqttTimeout: number | null = null
+// const MQTT_TIMEOUT_MS = 10000 // 10秒
 
 const resetMqttTimeout = () => {
-  if (mqttTimeout) clearTimeout(mqttTimeout)
-  mqttTimeout = window.setTimeout(() => {
-    console.log('MQTT超时未收到新消息')
-    closeMqtt()
-  }, MQTT_TIMEOUT_MS)
+  console.log('🚀关闭MQTT连接')
+  closeMqtt()
+  // if (mqttTimeout) clearTimeout(mqttTimeout)
+  // mqttTimeout = window.setTimeout(() => {
+  //   console.log('MQTT超时未收到新消息')
+  //   closeMqtt()
+  // }, MQTT_TIMEOUT_MS)
 }
 
 const MqttData = ref()

+ 1 - 1
src/views/device/detail/index.vue

@@ -322,7 +322,7 @@ const THRESHOLD = 2 // 去抖阈值
 
 let mqttClient: MqttClient | null = null
 let mqttTimeout: number | null = null
-const MQTT_TIMEOUT_MS = 10000 // 10
+const MQTT_TIMEOUT_MS = 1000 // 调整为1秒
 
 const resetMqttTimeout = () => {
   if (mqttTimeout) clearTimeout(mqttTimeout)