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打开新窗口