Browse Source

fix: unable to restart the device

Casper Dai 3 năm trước cách đây
mục cha
commit
16cf928529

+ 1 - 1
src/utils/mqtt.js

@@ -47,7 +47,7 @@ const whiteList = [
     val: willTopic
   }, {
     type: 'topic',
-    val: /^\d+\/\d+\/(status|screenshot)/
+    val: /^\d+\/\d+\/(status|screenshot|restart)/
   }, {
     val: /messageId/
   }

+ 1 - 1
src/views/device/detail/components/Running.vue

@@ -76,7 +76,7 @@ export default {
       }
     },
     ask () {
-      return send('status/ask')
+      return send('/status/ask')
     },
     invoke () {
       this.ask().catch(() => {

+ 2 - 2
src/views/device/detail/monitor.js

@@ -80,7 +80,7 @@ export function removeListener (type, cb) {
 
 function getTypeBySend (topic) {
   switch (topic) {
-    case 'status/ask':
+    case '/status/ask':
       return 'status'
     default:
       return null
@@ -88,7 +88,7 @@ function getTypeBySend (topic) {
 }
 
 export function send (topic, message) {
-  return publish(`${productId}/${deviceId}/${topic}`, JSON.stringify(message || { timestamp: Date.now() })).then(() => {
+  return publish(`${productId}/${deviceId}${topic}`, JSON.stringify(message || { timestamp: Date.now() })).then(() => {
     const inst = types.get(getTypeBySend(topic))
     if (inst && inst.type === Type.LOAD) {
       inst.loading = true