diff --git a/src/api/Dlink/index.js b/src/api/Dlink/index.js index 39a6163dc6..133968ea9c 100644 --- a/src/api/Dlink/index.js +++ b/src/api/Dlink/index.js @@ -77,3 +77,19 @@ export async function postTopic(Topic = '$dg/user/router/') { Vue.prototype.$mqttInfo = mqttInfo return submessage } + +export async function nopostTopic(Topic = '$dg/user/router/') { + const mqttInfo = { + href: location.href, + topic: Topic, + topicKey: + typeof Topic == 'string' + ? Vue.prototype.$dgiotBus.getTopicKeyBypage(Topic.split('/')[2]) + : Topic, + splitTopicKey: typeof Topic == 'string' ? Topic.split('/')[2] : Topic, + } + // MqttSubscribe + window.mqttInfo = window.dgiot.mqttInfo = mqttInfo + Vue.prototype.$mqttInfo = mqttInfo + return mqttInfo +} diff --git a/src/utils/utilwen.js b/src/utils/utilwen.js index a1fbf57921..5e6ebe2aaa 100644 --- a/src/utils/utilwen.js +++ b/src/utils/utilwen.js @@ -38,6 +38,7 @@ import { deleteTopic as unSubscribe, getTopic, postTopic as subscribe, + nopostTopic, } from '@/api/Dlink/index' // https://www.jianshu.com/p/abdee4e7875a /** @@ -567,6 +568,7 @@ export default { // 订阅方法挂载到全局变量上 2022年5月27日 Vue.prototype.$getTopic = getTopic Vue.prototype.$subscribe = subscribe + Vue.prototype.$nopostsubscribe = nopostTopic Vue.prototype.$unSubscribe = unSubscribe // 全局配置环境变量 Vue.prototype.$dgiot = window.dgiot diff --git a/src/views/CloudFunction/engine/channel.vue b/src/views/CloudFunction/engine/channel.vue index 8e9b014b2b..cb1655d28e 100644 --- a/src/views/CloudFunction/engine/channel.vue +++ b/src/views/CloudFunction/engine/channel.vue @@ -233,14 +233,6 @@ > {{ $translateTitle('developer.delete') }} - - - - - - - - @@ -549,6 +541,7 @@ @@ -581,64 +573,6 @@ - - - - - - - - - - - - @@ -701,7 +635,7 @@ topotopic: '', refreshFlag: '99', msgList: [], - submessage: '', + submessage: 'Starting the log' + `\n`, subtopic: '', pubtopic: '', channeindex: 0, @@ -1524,32 +1458,21 @@ }) this.refreshFlag = moment().format('x') this.submessage += Msg + `\n` - // subdialog.setValue(this.submessage) - // subdialog.gotoLine(subdialog.session.getLength()) }, async subProTopic(row) { - this.productinformation(row.objectId) this.subdialog = true this.subdialogid = row.objectId + this.channelid = row.objectId this.channelname = row.objectId this.subtopic = '$dg/user/channel/' + row.objectId + '/#' this.msgList = [] - this.submessage = '' - this.msgList = [] - let subInfo = { - router: this.router, - topic: this.subtopic, - qos: 2, - ttl: 1000 * 60 * 60 * 3, - } - await this.$subscribe(this.subtopic) + await this.$nopostsubscribe(this.subtopic) console.log(this.$mqttInfo) subupadte(row.objectId, 'start_logger') this.msgList = [] - this.submessage = '' + this.submessage = 'Starting the log' + `\n` this.$dgiotBus.$off(this.$mqttInfo.topicKey) this.$dgiotBus.$on(this.$mqttInfo.topicKey, (res) => { - console.log(res) const { payloadString } = res // 过滤登录时候,首页mqtt乱码的情况 this.mqttMsg(payloadString) @@ -1559,7 +1482,7 @@ async handleCloseSubdialog() { this.$dgiotBus.$off(this.$mqttInfo.topicKey) this.msgList = [] - this.submessage = '' + this.submessage = 'Starting the log' + `\n` subupadte(this.channelid, 'stop_logger') // this.$dgiotBus.$emit('MqttUnbscribe', this.topicKey, this.subtopic) await this.$unSubscribe(this.subtopic) diff --git a/src/views/CloudFunction/engine/components/mqttLog.vue b/src/views/CloudFunction/engine/components/mqttLog.vue index 61b1846771..2e7f75d77a 100644 --- a/src/views/CloudFunction/engine/components/mqttLog.vue +++ b/src/views/CloudFunction/engine/components/mqttLog.vue @@ -80,7 +80,7 @@ /> - + {{ $translateTitle('system.Accurate log') }} @@ -171,6 +171,8 @@