diff --git a/pages/home/control/automatic.vue b/pages/home/control/automatic.vue index bb104f7..20e3ed7 100644 --- a/pages/home/control/automatic.vue +++ b/pages/home/control/automatic.vue @@ -223,7 +223,7 @@ - {{ `【${selectedText} - 自动化】参数设置` }} + {{ `【${selectedText} - 自动化】条件设置` }} {{ slider.title }} diff --git a/pages/home/control/index.vue b/pages/home/control/index.vue index 1c4cf77..b86baf0 100644 --- a/pages/home/control/index.vue +++ b/pages/home/control/index.vue @@ -402,7 +402,9 @@ export default { ackMessage(topic, payload) { // 1. 先判断是否是目标订阅主题(如frontend/\\w+/control/\\w+") if ((topic !== this.mqttConfig.subscribeTopic+"/ack") - && (topic !== this.mqttConfig.subscribeTopic+"/listener")) return; + && (topic !== this.mqttConfig.subscribeTopic+"/listener") + && topic !== this.mqttConfig.subscribeTopic+"/config") return; + const regexWithGroup = /^frontend\/[^/]+\/dtu\/\d+\/(.+)$/; let msgData = {}; // 优化:捕获JSON解析异常 try { @@ -412,17 +414,22 @@ export default { return; } + const matchResult = topic.match(regexWithGroup); + const tag = matchResult[1]; // 提取结果:'1234567890' + // 3. 区分“回执”和“其他内容” - if (msgData.prop && "suc" in msgData) { + if (tag==='ack' && msgData.prop && "suc" in msgData) { this.handleCommandAck(msgData); - } else if ("msg" in msgData && "clientId" in msgData) { - if (mqttUtil.getMqttState().clientId === msgData.clientId) { - this.$modal.msg( - `${msgData.msg}` - ); - } - } else { - this.handleOtherContent(msgData,payload) + } + // else if (tag==='ack' && "msg" in msgData && "clientId" in msgData) { + // if (mqttUtil.getMqttState().clientId === msgData.clientId) { + // this.$modal.msg( + // `${msgData.msg}` + // ); + // } + // } + else { + this.handleOtherContent(msgData,tag) } }, @@ -456,10 +463,11 @@ export default { console.log(`指令[${commandField}=${commandValue}]执行${isSuccess ? "成功" : "失败"}`); }, - handleOtherContent(msgData,payload) { + handleOtherContent(msgData,tag) { // 业务逻辑:处理传感器数据、设备状态等 // 设备状态展示 - if (this.value !== 1) { + if (this.value === 1) return; + if (tag === 'listener') { var arr = ['jbk', "jbg", "jm1k", "jm1g", "jm2k", "jm2g", "jm3k", "jm3g","jlk","jlg"] const allKeysNumeric = Object.keys(msgData).some(key => arr.includes(key)); if (allKeysNumeric) { @@ -476,7 +484,9 @@ export default { this.fontStyle = 'font-size:16px;' this.makeSpecialData(msgData, true); } + } else if (tag === 'config') { if ("ventTotalLen" in msgData) { + console.info("参数设置:自动校准风口:",msgData.ventTotalLen) this.ventTotalLen = msgData.ventTotalLen; } }