【类 型】:fix 刷新操作时 触发订多次订阅

【原  因】:watch时 飞机列表每次都重新连 重新订阅 导致订阅多次
【过  程】:断开 重连mqtt
【影  响】:
This commit is contained in:
tk 2024-08-14 19:48:44 +08:00
parent e273ba9951
commit 99cc2c193a
2 changed files with 2 additions and 7 deletions

View File

@ -54,13 +54,7 @@ function doSubscribe (topic, callBack) {
}
store.state.app.mqttState = true // 标记mqtt链接成功 在线
// 订阅一个主题
this.client.subscribe(topic, { qos: 2 }, err => {
if (!err) {
store.dispatch('fetchLog', { content: topic + '主题订阅成功' })
} else {
store.dispatch('fetchLog', { content: topic + '主题订阅失败' })
}
})
this.client.subscribe(topic, { qos: 2 })
})
// 获取订阅主题的消息
this.client.on('message', (topic, message) => {

View File

@ -76,6 +76,7 @@ export default {
*/
airList (res) {
/* mqtt */
mqtt.mqttDestroy()// mqtt
mqtt.mqttConf()// mqtt
//
mqtt.doSubscribe('planeState/+', (mqttRes) => {