Просмотр исходного кода

feat(fulllink): support no mesh mode

Casper Dai 2 лет назад
Родитель
Сommit
f6bb0f5c51
1 измененных файлов с 33 добавлено и 2 удалено
  1. 33 2
      src/components/service/FullLink/index.vue

+ 33 - 2
src/components/service/FullLink/index.vue

@@ -67,6 +67,7 @@ import {
   Power
 } from '@/utils/adapter'
 import { getThirdPartyDevicesByThirdPartyDevice } from '@/api/mesh'
+import { getDevice } from '@/api/device'
 
 const LinkItems = Object.freeze([
   {
@@ -299,6 +300,36 @@ export default {
           : Math.min(width / 966, height / 420).toFixed(2)
       }
     },
+    onOnlyBox () {
+      this.linkDeviceMap = {
+        msr: Status.OK,
+        led: Status.ERROR,
+        [ThirdPartyDevice.BOX]: Status.ERROR,
+        [ThirdPartyDevice.GATEWAY]: Status.NONE,
+        [ThirdPartyDevice.LED_CAMERA]: Status.NONE,
+        [ThirdPartyDevice.TRAFFIC_CAMERA]: Status.NONE,
+        [ThirdPartyDevice.SENDING_CARD]: Status.NONE,
+        [ThirdPartyDevice.RECEIVING_CARD]: Status.NONE,
+        [ThirdPartyDevice.MULTI_FUNCTION_CARD]: Status.NONE
+      }
+      this.led = {
+        id: this.targetId,
+        onlineStatus: 0,
+        powerStatus: '',
+        by: [ThirdPartyDevice.BOX]
+      }
+      return this.updateBoxStatus().then(() => {
+        clearInterval(this.$timer)
+        this.$timer = setInterval(this.updateBoxStatus, 5000)
+        this.loaded = true
+      })
+    },
+    updateBoxStatus () {
+      return getDevice(this.targetId, { custom: true }).then(({ data }) => {
+        this.linkDeviceMap[ThirdPartyDevice.BOX] = data.onlineStatus === 1 ? Status.OK : Status.ERROR
+        this.onUpdateLed()
+      })
+    },
     getThirdPartyDevices () {
       Promise.all([
         getThirdPartyDevicesByThirdPartyDevice(this.targetId, [
@@ -313,8 +344,7 @@ export default {
         Promise.resolve(this.$multiCard)
       ]).then(([{ data: nodes }, multiCard]) => {
         if (!nodes.length) {
-          this.loaded = true
-          return
+          return this.onOnlyBox()
         }
         this.$deviceTypes = []
         const linkDeviceMap = {}
@@ -379,6 +409,7 @@ export default {
         }
         this.onUpdateLed()
         this.loaded = true
+        return true
       }).finally(() => {
         this.loading = false
       })