From 089bfaacf7309058454284cb920f651ced975857 Mon Sep 17 00:00:00 2001 From: Frost-ZX Date: Sun, 19 Jul 2026 20:03:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=90=8E=E8=BF=9B=E8=A1=8C=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E6=88=96=E5=B7=B2=E8=BF=9E=E6=8E=A5=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=BB=E9=A2=98=EF=BC=8C=E8=AE=A2=E9=98=85=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=88=97=E8=A1=A8=E7=9A=84=E5=86=85=E5=AE=B9=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/mqtt-manager.js | 9 +++++---- app/src/renderer/src/stores/mqtt.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/mqtt-manager.js b/app/src/main/mqtt-manager.js index cd13303..e0d3c31 100644 --- a/app/src/main/mqtt-manager.js +++ b/app/src/main/mqtt-manager.js @@ -450,15 +450,16 @@ class MqttManager { addTopic(serverId, topic, qos = 1) { let server = this.servers.get(serverId); if (!server) { - return false; + return null; } if (server.topics.find((t) => t.topic === topic)) { - return false; + return null; } let topicId = 'topic_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6); - server.topics.push({ id: topicId, topic, qos, subscribed: false }); + let newTopic = { id: topicId, topic, qos, subscribed: false }; + server.topics.push(newTopic); this.saveData(); @@ -467,7 +468,7 @@ class MqttManager { this._doSubscribe(serverId, topic, { qos }); } - return true; + return newTopic; } diff --git a/app/src/renderer/src/stores/mqtt.js b/app/src/renderer/src/stores/mqtt.js index ff91ea1..691b554 100644 --- a/app/src/renderer/src/stores/mqtt.js +++ b/app/src/renderer/src/stores/mqtt.js @@ -191,7 +191,7 @@ export function useMqttStore() { if (result) { let srv = servers.value.find((s) => s.id === serverId); if (srv) { - srv.topics.push({ topic, qos, subscribed: false }); + srv.topics.push(result); } }