From f47a7dbfbfd28eac037c88a15d3e0f0965b0d429 Mon Sep 17 00:00:00 2001 From: Poised_flw Date: Fri, 31 Dec 2021 12:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E5=8F=91=E9=80=81=E8=80=85=E8=87=AA=E5=B7=B1=EF=BC=88?= =?UTF-8?q?=E5=B9=BF=E6=92=AD=E6=96=B9=E5=BC=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/ipc.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/main/ipc.js b/app/main/ipc.js index 547df0a..efd0781 100644 --- a/app/main/ipc.js +++ b/app/main/ipc.js @@ -42,7 +42,7 @@ const { createClient } = require('redis') subscriber.subscribe('openMap', message => { const windows = BrowserWindow.getAllWindows() const found = windows.find((window) => { - return window[SUSPENSION_WINDOW_FLAG] + return window[MAIN_WINDOW_FLAG] }); found.webContents.send('openMap', JSON.parse(message)) }) @@ -51,7 +51,7 @@ const { createClient } = require('redis') subscriber.pSubscribe('openMap*', (message, channel) => { const windows = BrowserWindow.getAllWindows() const found = windows.find((window) => { - return window[SUSPENSION_WINDOW_FLAG] + return window[MAIN_WINDOW_FLAG] }); found.webContents.send(channel, JSON.parse(message)) }) @@ -288,13 +288,14 @@ module.exports = () => { }) // 通信桥梁 - ipc.on('bridge', function (event, { channel, ...message }) { - console.log('bridge message', channel, message) + ipc.on('bridge', function (event, { channel, targetId, ...message }) { const windows = BrowserWindow.getAllWindows() - const found = windows.find((window) => { - return window[SUSPENSION_WINDOW_FLAG] - }); - found.webContents.send(channel, message) + for (let win of windows) { + if (win.webContents.id === event.sender.id) continue; + if (!targetId || win[targetId]) { + win.webContents.send(channel, message) + } + } }) // 通过main打开新窗口