Browse Source

feat: multi function card binding detection

Casper Dai 2 years ago
parent
commit
3539c1f14e

+ 3 - 2
src/api/device.js

@@ -552,11 +552,12 @@ export function getDeviceAttentionList (options) {
   })
 }
 
-export function getStatusReport (id) {
+export function getStatusReport (id, options) {
   return request({
     url: '/device/screenPower/latestStatusReport',
     method: 'POST',
-    data: { deviceIds: id }
+    data: { deviceIds: id },
+    ...options
   })
 }
 

+ 3 - 3
src/components/service/FullLink/index.vue

@@ -55,9 +55,9 @@
 <script>
 import { ThirdPartyDevice } from '@/constant'
 import {
-  Power,
-  Status
-} from '@/utils/adapter/nova'
+  Status,
+  Power
+} from '@/utils/adapter'
 import { getThirdPartyDevicesByThirdPartyDevice } from '@/api/mesh'
 
 const LinkItems = Object.freeze([

+ 13 - 0
src/utils/adapter/constant.js

@@ -0,0 +1,13 @@
+export const Status = {
+  NONE: -2,
+  LOADING: -1,
+  OK: 0,
+  ERROR: 1,
+  WARNING: 2
+}
+
+export const Power = {
+  LOADING: -1,
+  ON: 0,
+  OFF: 255
+}

+ 2 - 275
src/utils/adapter/index.js

@@ -1,278 +1,5 @@
-import { ThirdPartyDevice } from '@/constant'
-import {
-  WillTopic,
-  createClient,
-  decodePayload
-} from '@/utils/mqtt'
-import { getStatusReport } from '@/api/device'
-import {
-  Power,
-  Status,
-  GET_POWER_STATUS,
-  GET_RECEIVER_TOPOLOGY,
-  GET_RECEIVER_INFO,
-  parseCachePower,
-  getPowerStatusByMessage,
-  getReceivingCardTopologyByMessage,
-  getReceivingCardStatusByMessage
-} from './nova'
+export * from './constant'
 
 export * from './nova'
 
-const deviceCache = new Map()
-const cbMap = new Map()
-const injectMap = new Map()
-
-let client = null
-export function startMonitor () {
-  if (client) {
-    return
-  }
-  client = createClient({
-    will: {
-      topic: WillTopic,
-      payload: 'Thirdparty device monitor has died.',
-      qos: 0,
-      retain: false
-    }
-  })
-
-  client.on('error', err => {
-    console.log('Monitor connection error: ', err)
-  })
-
-  client.on('connect', () => {
-    console.log('Monitor connected')
-  })
-
-  client.on('disconnect', () => {
-    console.log('Monitor disconnect')
-  })
-
-  client.on('reconnect', () => {
-    console.log('Monitor reconnecting...')
-  })
-
-  client.on('offline', () => {
-    console.log('Monitor offline')
-  })
-
-  client.on('close', () => {
-    console.log('Monitor closed')
-  })
-
-  client.on('message', (topic, payload) => {
-    console.log('Monitor topic', topic)
-    const result = /^(\d+)\/(\d+)\/(screen|multifunctionCard\/invoke\/reply)$/.exec(topic)
-    if (!result) {
-      return
-    }
-    const id = result[2]
-    console.log('monitor cache', id)
-    const message = JSON.parse(decodePayload(topic, payload))
-
-    const timestamp = Number(message.timestamp) || Date.now()
-
-    if (result[3] === 'screen') {
-      const { versionName, versionCode, externalUsage, ramUsage, volume } = message
-      emit(id, 'screen', {
-        timestamp,
-        versionName,
-        versionCode,
-        externalUsage,
-        ramUsage,
-        volume
-      })
-      return
-    }
-
-    if (message.function === GET_POWER_STATUS) {
-      const data = getPowerStatusByMessage(message)
-      if (data.success) {
-        emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
-          timestamp,
-          ...data.data
-        })
-      }
-    } else if (message.function === GET_RECEIVER_INFO) {
-      const data = getReceivingCardStatusByMessage(message)
-      if (data.success) {
-        emit(id, ThirdPartyDevice.RECEIVING_CARD, {
-          timestamp,
-          ...data.data
-        })
-      }
-    } else if (message.function === GET_RECEIVER_TOPOLOGY) {
-      const data = getReceivingCardTopologyByMessage(message)
-      if (data.success) {
-        emit(id, 'topology', {
-          timestamp,
-          ...data.data
-        })
-      }
-    } else {
-      injectMap.get(id)?.forEach(cb => {
-        cb(message)
-      })
-    }
-  })
-
-  client.subscribe([
-    '+/+/screen',
-    '+/+/multifunctionCard/invoke/reply'
-  ])
-}
-
-function emit (id, key, value) {
-  const cache = getCacheById(id)
-  cache[key] = value
-  cbMap.get(id)?.forEach(cb => {
-    cb(cache, key)
-  })
-}
-
-export function getCacheById (id) {
-  let cache = deviceCache.get(id)
-  if (!cache) {
-    deviceCache.set(id, cache = {
-      [ThirdPartyDevice.MULTI_FUNCTION_CARD]: {
-        status: Status.LOADING,
-        switchStatus: Power.NONE,
-        powers: []
-      },
-      [ThirdPartyDevice.RECEIVING_CARD]: {
-        status: Status.LOADING,
-        receivers: []
-      },
-      topology: null,
-      screen: null
-    })
-  }
-  return cache
-}
-
-export function addListener (id, cb) {
-  let cbSet = cbMap.get(id)
-  if (!cbSet) {
-    cbMap.set(id, cbSet = new Set())
-  }
-  if (cbSet.has(cb)) {
-    console.log('monitor', id, '->', 'exsit')
-    return
-  }
-  console.log('monitor add', id, '->', 'success')
-  cbSet.add(cb)
-  const cache = getCacheById(id)
-  if (cache[ThirdPartyDevice.MULTI_FUNCTION_CARD].status === Status.LOADING) {
-    console.log('monitor', id, '->', 'add task for multi card')
-    addTask(id)
-  }
-  cb(cache)
-}
-
-export function removeListener (id, cb) {
-  const cbSet = cbMap.get(id)
-  if (!cbSet || !cbSet.has(cb)) {
-    console.log('monitor', id, '->', 'not exsit')
-    return
-  }
-  console.log('monitor remove', id, '->', 'success')
-  cbSet.delete(cb)
-}
-
-export function addInjectListener (id, cb) {
-  let cbSet = injectMap.get(id)
-  if (!cbSet) {
-    injectMap.set(id, cbSet = new Set())
-  }
-  if (cbSet.has(cb)) {
-    console.log('inject', id, '->', 'exsit')
-    return
-  }
-  console.log('inject add', id, '->', 'success')
-  cbSet.add(cb)
-}
-
-export function removeInjectListener (id, cb) {
-  const cbSet = injectMap.get(id)
-  if (!cbSet || !cbSet.has(cb)) {
-    console.log('inject', id, '->', 'not exsit')
-    return
-  }
-  console.log('inject remove', id, '->', 'success')
-  cbSet.delete(cb)
-}
-
-let waiting = new Set()
-let running = new Set()
-let fetching = false
-let started = false
-
-function addTask (id) {
-  if (fetching) {
-    waiting.add(id)
-  } else {
-    running.add(id)
-    if (!started) {
-      Promise.resolve().then(startTask)
-    }
-  }
-}
-
-function startTask () {
-  if (waiting.size) {
-    running = new Set([...running, ...waiting])
-    waiting = new Set()
-  }
-  console.log('monitor task', running.size)
-  if (running.size) {
-    started = true
-    getPowerByIds()
-  }
-}
-
-function getPowerByIds () {
-  fetching = true
-  const ids = [...running]
-  running = new Set()
-  getStatusReport(ids).then(
-    ({ data }) => {
-      const map = {}
-      data.forEach(item => {
-        map[item.deviceId] = item
-      })
-      const now = Date.now()
-      ids.forEach(id => {
-        if (getCacheById(id)[ThirdPartyDevice.MULTI_FUNCTION_CARD].status === Status.LOADING) {
-          const multiCard = map[id]
-          if (multiCard) {
-            const timestamp = Number(multiCard.reportTimestamp)
-            if (now - timestamp > 60000 || multiCard.switchStatus === Power.LOADING) {
-              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
-                status: Status.WARNING,
-                timestamp,
-                switchStatus: Power.LOADING,
-                powers: []
-              })
-            } else {
-              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
-                status: Status.OK,
-                timestamp,
-                ...parseCachePower(multiCard)
-              })
-            }
-          } else {
-            emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, { status: Status.NONE })
-          }
-        }
-      })
-    },
-    () => {
-      running = new Set([...running, ...ids])
-    }
-  ).then(() => {
-    fetching = false
-    started = false
-    setTimeout(startTask, 500)
-  })
-}
+export * from './monitor'

+ 331 - 0
src/utils/adapter/monitor.js

@@ -0,0 +1,331 @@
+import { ThirdPartyDevice } from '@/constant'
+import {
+  WillTopic,
+  createClient,
+  decodePayload
+} from '@/utils/mqtt'
+import { getStatusReport } from '@/api/device'
+import { getThirdPartyDevicesByThirdPartyDevice } from '@/api/mesh'
+import {
+  Status,
+  Power
+} from './constant'
+import {
+  GET_POWER_STATUS,
+  GET_RECEIVER_TOPOLOGY,
+  GET_RECEIVER_INFO,
+  parseCachePower,
+  getPowerStatusByMessage,
+  getReceivingCardTopologyByMessage,
+  getReceivingCardStatusByMessage
+} from './nova'
+
+const TIMEOUT_MILLISECOND = 120000
+
+const deviceCache = new Map()
+const cbMap = new Map()
+const injectMap = new Map()
+
+let client = null
+export function startMonitor () {
+  if (client) {
+    return
+  }
+  client = createClient({
+    will: {
+      topic: WillTopic,
+      payload: 'Thirdparty device monitor has died.',
+      qos: 0,
+      retain: false
+    }
+  })
+
+  client.on('error', err => {
+    console.log('Monitor connection error: ', err)
+  })
+
+  client.on('connect', () => {
+    console.log('Monitor connected')
+  })
+
+  client.on('disconnect', () => {
+    console.log('Monitor disconnect')
+  })
+
+  client.on('reconnect', () => {
+    console.log('Monitor reconnecting...')
+  })
+
+  client.on('offline', () => {
+    console.log('Monitor offline')
+  })
+
+  client.on('close', () => {
+    console.log('Monitor closed')
+  })
+
+  client.on('message', (topic, payload) => {
+    console.log('Monitor topic', topic)
+    const result = /^(\d+)\/(\d+)\/(screen|multifunctionCard\/invoke\/reply)$/.exec(topic)
+    if (!result) {
+      return
+    }
+    const id = result[2]
+    console.log('monitor cache', id)
+    const message = JSON.parse(decodePayload(topic, payload))
+
+    const timestamp = Number(message.timestamp) || Date.now()
+
+    if (result[3] === 'screen') {
+      const { versionName, versionCode, externalUsage, ramUsage, volume } = message
+      emit(id, 'screen', {
+        timestamp,
+        versionName,
+        versionCode,
+        externalUsage,
+        ramUsage,
+        volume
+      })
+      return
+    }
+
+    if (message.function === GET_POWER_STATUS) {
+      const data = getPowerStatusByMessage(message)
+      if (data.success) {
+        emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+          timestamp,
+          ...data.data
+        })
+      }
+    } else if (message.function === GET_RECEIVER_INFO) {
+      const data = getReceivingCardStatusByMessage(message)
+      if (data.success) {
+        emit(id, ThirdPartyDevice.RECEIVING_CARD, {
+          timestamp,
+          ...data.data
+        })
+      }
+    } else if (message.function === GET_RECEIVER_TOPOLOGY) {
+      const data = getReceivingCardTopologyByMessage(message)
+      if (data.success) {
+        emit(id, 'topology', {
+          timestamp,
+          ...data.data
+        })
+      }
+    } else {
+      injectMap.get(id)?.forEach(cb => {
+        cb(message)
+      })
+    }
+  })
+
+  client.subscribe([
+    '+/+/screen',
+    '+/+/multifunctionCard/invoke/reply'
+  ])
+}
+
+function emit (id, key, value) {
+  const cache = getCacheById(id)
+  cache[key] = value
+  cbMap.get(id)?.forEach(cb => {
+    cb(cache, key)
+  })
+}
+
+export function getCacheById (id) {
+  let cache = deviceCache.get(id)
+  if (!cache) {
+    deviceCache.set(id, cache = {
+      [ThirdPartyDevice.MULTI_FUNCTION_CARD]: {
+        status: Status.LOADING,
+        switchStatus: Power.LOADING,
+        powers: []
+      },
+      [ThirdPartyDevice.RECEIVING_CARD]: {
+        status: Status.LOADING,
+        receivers: []
+      },
+      topology: null,
+      screen: null
+    })
+  }
+  return cache
+}
+
+export function addListener (id, cb) {
+  let cbSet = cbMap.get(id)
+  if (!cbSet) {
+    cbMap.set(id, cbSet = new Set())
+  }
+  if (cbSet.has(cb)) {
+    console.log('monitor', id, '->', 'exsit')
+    return
+  }
+  console.log('monitor add', id, '->', 'success')
+  cbSet.add(cb)
+  const cache = getCacheById(id)
+  checkMultiCard(id, cache[ThirdPartyDevice.MULTI_FUNCTION_CARD])
+  cb(cache)
+}
+
+function checkMultiCard (id, multiCard) {
+  switch (multiCard.status) {
+    case Status.LOADING:
+      console.log('monitor', id, '->', 'add task')
+      addTask(id)
+      break
+    case Status.OK:
+      if (Date.now() - multiCard.timestamp > TIMEOUT_MILLISECOND) {
+        multiCard.status = Status.WARNING
+      }
+      break
+    default:
+      break
+  }
+}
+
+export function removeListener (id, cb) {
+  const cbSet = cbMap.get(id)
+  if (!cbSet || !cbSet.has(cb)) {
+    console.log('monitor', id, '->', 'not exsit')
+    return
+  }
+  console.log('monitor remove', id, '->', 'success')
+  cbSet.delete(cb)
+}
+
+export function addInjectListener (id, cb) {
+  let cbSet = injectMap.get(id)
+  if (!cbSet) {
+    injectMap.set(id, cbSet = new Set())
+  }
+  if (cbSet.has(cb)) {
+    console.log('inject', id, '->', 'exsit')
+    return
+  }
+  console.log('inject add', id, '->', 'success')
+  cbSet.add(cb)
+}
+
+export function removeInjectListener (id, cb) {
+  const cbSet = injectMap.get(id)
+  if (!cbSet || !cbSet.has(cb)) {
+    console.log('inject', id, '->', 'not exsit')
+    return
+  }
+  console.log('inject remove', id, '->', 'success')
+  cbSet.delete(cb)
+}
+
+let waiting = new Set()
+let queue = new Set()
+let fetching = false
+let started = false
+
+function addTask (id) {
+  if (fetching) {
+    if (queue.has(id)) {
+      console.log('task exsit', id)
+    } else {
+      waiting.add(id)
+    }
+  } else {
+    queue.add(id)
+    flush()
+  }
+}
+
+function flush () {
+  if (!started && (queue.size || waiting.size)) {
+    queue = new Set([...queue, ...waiting])
+    waiting = new Set()
+    started = true
+    Promise.resolve().then(startTask)
+  }
+}
+
+function startTask () {
+  fetching = true
+  console.log('monitor task', queue.size)
+  const ids = [...queue]
+  getStatusReport(ids, { background: true, custom: true }).then(
+    async ({ data }) => {
+      const map = {}
+      data.forEach(item => {
+        map[item.deviceId] = item
+      })
+      const now = Date.now()
+      const errorSet = new Set()
+      for (let i = 0; i < ids.length; i++) {
+        const id = ids[i]
+        if (getCacheById(id)[ThirdPartyDevice.MULTI_FUNCTION_CARD].status !== Status.LOADING) {
+          continue
+        }
+        const multiCard = map[id]
+        // 未上报过数据需判断是否绑定了多功能卡
+        if (!multiCard) {
+          try {
+            const { data } = await getThirdPartyDevicesByThirdPartyDevice(id, [
+              ThirdPartyDevice.MULTI_FUNCTION_CARD
+            ], { background: true, custom: true })
+            if (data?.[0]?.instance) {
+              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+                status: Status.WARNING,
+                timestamp: Date.now(),
+                switchStatus: Power.LOADING,
+                powers: []
+              })
+            } else {
+              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, { status: Status.NONE })
+            }
+          } catch (e) {
+            errorSet.add(id)
+          }
+          continue
+        }
+        const timestamp = Number(multiCard.reportTimestamp)
+        const powerInfo = parseCachePower(multiCard)
+        // 超时未上报的需判断是否解绑了多功能卡
+        if (now - timestamp > TIMEOUT_MILLISECOND) {
+          try {
+            const { data } = await getThirdPartyDevicesByThirdPartyDevice(id, [
+              ThirdPartyDevice.MULTI_FUNCTION_CARD
+            ], { background: true, custom: true })
+            if (data?.[0]?.instance) {
+              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+                status: Status.WARNING,
+                timestamp,
+                ...powerInfo
+              })
+            } else {
+              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, { status: Status.NONE })
+            }
+          } catch (e) {
+            errorSet.add(id)
+          }
+          continue
+        }
+        if (multiCard.switchStatus === Power.LOADING) {
+          emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+            status: Status.WARNING,
+            timestamp,
+            ...powerInfo
+          })
+          continue
+        }
+        emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+          status: Status.OK,
+          timestamp,
+          ...powerInfo
+        })
+      }
+      queue = errorSet
+    }
+  ).then(() => {
+    fetching = false
+    started = false
+    setTimeout(flush, 500)
+  })
+}

+ 5 - 14
src/utils/adapter/nova.js

@@ -1,20 +1,11 @@
+import {
+  Status,
+  Power
+} from './constant'
+
 export const TOPIC_KEY = 'multifunctionCard/invoke'
 export const REPLY_TOPIC_KEY = 'multifunctionCard/invoke/reply'
 
-export const Status = {
-  NONE: -2,
-  LOADING: -1,
-  OK: 0,
-  ERROR: 1,
-  WARNING: 2
-}
-
-export const Power = {
-  LOADING: -1,
-  ON: 0,
-  OFF: 255
-}
-
 // 多功能卡处理
 // 针对自实行的如9520设备,电源上报类型均为默认
 // nova自身支持类型配置,此时需固定类型,例如屏电源统一为【屏体电源】

+ 16 - 11
src/views/dashboard/components/Device.vue

@@ -21,7 +21,7 @@
           @click.stop="screenshot"
         />
       </template>
-      <template v-if="hasPowerStatus">
+      <template v-if="hasStatus">
         <i
           v-if="isOnline && hasPower"
           class="l-flex__none c-sibling-item near o-device__status"
@@ -94,7 +94,7 @@
         </span>
       </template>
       <i
-        v-else-if="!hasPowerStatus"
+        v-else-if="!hasStatus"
         class="l-flex__auto l-flex--row el-icon-loading"
       />
       <div
@@ -127,13 +127,11 @@ import {
   EventPriorityInfo
 } from '@/constant'
 import {
+  Status,
+  Power,
   addListener,
   removeListener
 } from '@/utils/adapter'
-import {
-  Power,
-  Status
-} from '@/utils/adapter/nova'
 import { ScreenshotCache } from '@/utils/cache'
 import {
   ONE_DAY,
@@ -200,17 +198,17 @@ export default {
     isOnline () {
       return this.device.onlineStatus === 1
     },
-    hasPowerStatus () {
-      return !this.hasPower || this.hasPowerRealStatus
+    hasStatus () {
+      return !this.isOnline || !this.hasPower || this.hasPowerRealStatus
     },
     isPowerOpened () {
       return !this.hasPower || this.hasPowerRealStatus && (this.powerStatus === Status.OK && this.switchStatus !== Power.OFF)
     },
     isRealOnline () {
-      return this.isOnline && this.isPowerOpened
+      return this.hasStatus && this.isOnline && this.isPowerOpened
     },
     isRealOffline () {
-      return this.hasPowerRealStatus && !this.isRealOnline
+      return this.hasStatus && !this.isRealOnline
     },
     switchStatusClass () {
       if (this.powerStatus === Status.WARNING) {
@@ -243,6 +241,11 @@ export default {
           this.onReset()
         }
       }
+      if (val) {
+        addListener(this.device.id, this.onMessage)
+      } else {
+        removeListener(this.device.id, this.onMessage)
+      }
     }
   },
   created () {
@@ -250,7 +253,9 @@ export default {
     this.$refreshTimer = -1
   },
   mounted () {
-    addListener(this.device.id, this.onMessage)
+    if (this.isOnline) {
+      addListener(this.device.id, this.onMessage)
+    }
     if (this.always) {
       this.intoView()
     } else {

+ 1 - 1
src/views/device/detail/components/Anolg/components/BoxOperation.vue

@@ -23,7 +23,7 @@ import { publish } from '@/utils/mqtt'
 import {
   LINK_MULTI,
   RELEASE_MULTI
-} from '@/utils/adapter/nova'
+} from '@/utils/adapter'
 
 export default {
   name: 'AnolgBoxOperation',

+ 1 - 7
src/views/device/detail/components/Anolg/index.vue

@@ -20,10 +20,6 @@
       class="c-sibling-item--v far"
       :device="device"
     />
-    <power-box-operation
-      class="c-sibling-item--v far"
-      :device="device"
-    />
   </div>
 </template>
 
@@ -33,7 +29,6 @@ import Deviation from './components/Deviation.vue'
 import BoxStatus from './components/BoxStatus.vue'
 import Monitor from './components/Monitor.vue'
 import BoxOperation from './components/BoxOperation.vue'
-import PowerBoxOperation from './components/PowerBoxOperation.vue'
 
 export default {
   name: 'Anolg',
@@ -42,8 +37,7 @@ export default {
     Deviation,
     BoxStatus,
     Monitor,
-    BoxOperation,
-    PowerBoxOperation
+    BoxOperation
   },
   props: {
     device: {

+ 2 - 2
src/views/device/detail/components/DeviceExternal/components/ReceivingCard.vue

@@ -45,9 +45,9 @@ import { ThirdPartyDevice } from '@/constant'
 import { publish } from '@/utils/mqtt'
 import {
   addListener,
-  removeListener
+  removeListener,
+  triggerReceivingCardTopologyReporting
 } from '@/utils/adapter'
-import { triggerReceivingCardTopologyReporting } from '@/utils/adapter/nova'
 import { getThirdPartyDevicesByThirdPartyDevice } from '@/api/mesh'
 import { getReceivingCardTopology } from '@/api/external'
 

+ 6 - 7
src/views/device/detail/components/DeviceInfo/components/Power.vue

@@ -37,17 +37,16 @@ import {
 import { parseTime } from '@/utils'
 import { publish } from '@/utils/mqtt'
 import {
+  Status,
+  Power,
+  RELAY_KEY,
+  GET_POWER_STATUS,
+  GET_MULTI_POWER_TIMING,
   addListener,
   removeListener,
   addInjectListener,
   removeInjectListener
 } from '@/utils/adapter'
-import {
-  Status,
-  RELAY_KEY,
-  GET_POWER_STATUS,
-  GET_MULTI_POWER_TIMING
-} from '@/utils/adapter/nova'
 import { toDate } from '@/utils/event'
 
 const ErrorMessage = {
@@ -166,7 +165,7 @@ export default {
           }
         })
         this.$typeMap = map
-        this.emptyWarningTip = `直至 ${timestamp} 未收到上报数据`
+        this.emptyWarningTip = `电源状态异常,${multiCard.switchStatus === Power.LOADING ? '检测' : '最后上报'}}时间 ${this.timestamp}`
         this.hasMulti = multiCard.status === Status.OK
         this.$refs.powerTable?.pageTo()
       }

+ 6 - 8
src/views/device/detail/components/DeviceInvoke/MultifunctionCardPowerSwitch.vue

@@ -105,12 +105,6 @@ import {
   parseTime,
   transformToCron
 } from '@/utils'
-import {
-  addListener,
-  removeListener,
-  addInjectListener,
-  removeInjectListener
-} from '@/utils/adapter'
 import {
   Status,
   GET_POWER_STATUS,
@@ -121,8 +115,12 @@ import {
   SET_MULTI_POWER_TIMING,
   GET_RELAY_POWER_TIMING,
   SET_RELAY_POWER_MANUAL,
-  SET_RELAY_POWER_TIMING
-} from '@/utils/adapter/nova'
+  SET_RELAY_POWER_TIMING,
+  addListener,
+  removeListener,
+  addInjectListener,
+  removeInjectListener
+} from '@/utils/adapter'
 import { toDate } from '@/utils/event'
 import {
   savePowerLogger,

+ 2 - 4
src/views/device/power/components/DevicePower.vue

@@ -2,13 +2,11 @@
 import { ThirdPartyDevice } from '@/constant'
 import { parseTime } from '@/utils'
 import {
+  Status,
+  Power,
   addListener,
   removeListener
 } from '@/utils/adapter'
-import {
-  Power,
-  Status
-} from '@/utils/adapter/nova'
 
 export default {
   name: 'DevicePower',

+ 3 - 5
src/views/device/power/components/DevicePowerTask.vue

@@ -2,16 +2,14 @@
 import { ThirdPartyDevice } from '@/constant'
 import { publish } from '@/utils/mqtt'
 import {
+  Status,
+  GET_MULTI_POWER_TIMING,
+  SET_MULTI_POWER_TIMING,
   addListener,
   removeListener,
   addInjectListener,
   removeInjectListener
 } from '@/utils/adapter'
-import {
-  Status,
-  GET_MULTI_POWER_TIMING,
-  SET_MULTI_POWER_TIMING
-} from '@/utils/adapter/nova'
 import { savePowerLogger } from '@/api/platform'
 
 export default {

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

@@ -100,7 +100,7 @@ import {
   subscribe,
   unsubscribe
 } from '@/utils/mqtt'
-import { Status } from '@/utils/adapter/nova'
+import { Status } from '@/utils/adapter'
 import {
   toggleDevicePower,
   getOperationResult,