From ffd2d238c2fd438c19114ccb6535c86a50705f29 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 24 Aug 2026 02:20:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(bridge):=20WS=E6=A1=A5=E6=8E=A5=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=9B=9E=E6=98=BE=5FmsgId/=5FcallId=EF=BC=8C=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E4=B8=A5=E6=A0=BC=E6=8C=89ID=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=B9=BF=E6=92=AD=E8=AF=AF=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/wsServer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/wsServer.js b/core/wsServer.js index 893b0e1..e26799a 100644 --- a/core/wsServer.js +++ b/core/wsServer.js @@ -250,9 +250,11 @@ class WSServer { ws.send(JSON.stringify({ success: false, message: '消息解析失败' })); return; } - const { method, data, _callId } = parsed; + const { method, data, _callId, _msgId } = parsed; + // 统一回显请求 ID:优先 _msgId(Electron 桥接),兼容 _callId(页面直连) + const replyId = _msgId || _callId; if (!method) { - ws.send(JSON.stringify({ success: false, message: 'method不能为空', _callId })); + ws.send(JSON.stringify({ success: false, message: 'method不能为空', _msgId: replyId, _callId: replyId })); return; } // 支持多级目录结构,如 index.index.index @@ -265,17 +267,18 @@ class WSServer { if (typeof serviceFn === 'function') { try { const result = await serviceFn(data); - ws.send(JSON.stringify({ success: true, method, result, _callId })); + ws.send(JSON.stringify({ success: true, method, result, _msgId: replyId, _callId: replyId })); } catch (err) { //console.log(err); - ws.send(JSON.stringify({ success: false, method, message: '服务方法执行失败: ' + err.message, _callId })); + ws.send(JSON.stringify({ success: false, method, message: '服务方法执行失败: ' + err.message, _msgId: replyId, _callId: replyId })); } } else { ws.send(JSON.stringify({ success: false, method, message: '未找到对应服务方法', - _callId, + _msgId: replyId, + _callId: replyId, debug: { method, methodPath,