自从 electron 更新 11 后,contextIsolation: 被设置成默认 true, 需要配合使用。
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})
win.loadFile('index.html')
}

