使用new BrowserWindow()创建新窗口后,原窗口不能点击了。

主进程中使用new BrowserWindow()创建窗口,
加载网页,网页里面点击按钮弹出一个新窗口加载新链接,
这个时候原来的窗口不能点击了。
// 创建窗口的方法

// 创建窗口的方发
function createWindow(icon, resizable) {
  const uuid = uuidv1();
  Menu.setApplicationMenu(null);
  let window = new BrowserWindow({
    width: width,
    height: height,
    title: '云游加速器',
    icon: logo,
    resizable: resizable,
    transparent: false,
    defaultFontFamily: {
      standard: '微软雅黑'
    },
    webPreferences: {
      nodeIntegration: true,
    }
  });
  if (DEBUG) {
    window.webContents.toggleDevTools();
  }
  const result = {uuid: uuid, instance: window};
  electronWindows.push(result);
  return result
}

function indexOfWindow(window) {
let index = -1;
for (let i = 0; i < electronWindows.length; i++) {
if (electronWindows[i].uuid === window.uuid) {
index = i;
}
}
return index;
}

function removeWindow(window) {
const index = indexOfWindow(window);
if (index >= 0) {
electronWindows.splice(index, 1);
}
}

app.on('ready', () => {
  mainWindow = createWindow(logo, false);
  mainWindow.instance.loadURL('http://www.baidu.com');
  mainWindow.instance.on('closed', () => {
    console.log('关闭主窗口');
    removeWindow(mainWindow);
    mainWindow = null;
  });
});

ipcMain.on('charge', (event, data) => {
let chargeWindow = createWindow(logo, true);
chargeWindow.instance.loadURL(data);
chargeWindow.instance.on('closed', () => {
console.log('弹窗关闭');
removeWindow(chargeWindow);
chargeWindow = null;
});
});

https://www.v2ex.com/amp/t/417758