Prechádzať zdrojové kódy

fix: power detection

Casper Dai 2 rokov pred
rodič
commit
b56a075c28

+ 6 - 9
src/utils/adapter/index.js

@@ -219,7 +219,7 @@ function getPowerByIds () {
           const multiCard = map[id]
           if (multiCard) {
             const timestamp = Number(multiCard.reportTimestamp)
-            if (now - timestamp > 60000) {
+            if (now - timestamp > 60000 || multiCard.switchStatus === Power.LOADING) {
               emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
                 status: Status.WARNING,
                 timestamp,
@@ -227,14 +227,11 @@ function getPowerByIds () {
                 powers: []
               })
             } else {
-              const powerData = parseCachePower(map[id])
-              if (powerData.switchStatus > Power.LOADING) {
-                emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
-                  status: Status.OK,
-                  timestamp,
-                  ...powerData
-                })
-              }
+              emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, {
+                status: Status.OK,
+                timestamp,
+                ...parseCachePower(multiCard)
+              })
             }
           } else {
             emit(id, ThirdPartyDevice.MULTI_FUNCTION_CARD, { status: Status.NONE })

+ 1 - 1
src/views/dashboard/components/Device.vue

@@ -204,7 +204,7 @@ export default {
       return !this.hasPower || this.hasPowerRealStatus
     },
     isPowerOpened () {
-      return this.hasPowerStatus && (this.powerStatus === Status.NONE || this.powerStatus === Status.OK && this.switchStatus !== Power.OFF)
+      return !this.hasPower || this.hasPowerRealStatus && (this.powerStatus === Status.OK && this.switchStatus !== Power.OFF)
     },
     isRealOnline () {
       return this.isOnline && this.isPowerOpened