Upgrade electron from 13 to 15 (#1764)

* ^ Update electron 13.x > 15.x

* ! Fix child window options due to breaking change in electron 14.x

Breaking change:
https://github.com/electron/electron/pull/28550
Child windows no longer inherit BrowserWindow construction options from their parents.
This commit is contained in:
PikachuEXE 2021-11-10 22:51:21 +08:00 committed by GitHub
parent ed188eba3e
commit 413219525c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 10 deletions

View File

@ -109,7 +109,7 @@
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"copy-webpack-plugin": "^9.0.1", "copy-webpack-plugin": "^9.0.1",
"css-loader": "5.2.6", "css-loader": "5.2.6",
"electron": "^13.5.1", "electron": "^15.3.1",
"electron-builder": "^22.11.7", "electron-builder": "^22.11.7",
"electron-builder-squirrel-windows": "^22.13.1", "electron-builder-squirrel-windows": "^22.13.1",
"electron-debug": "^3.2.0", "electron-debug": "^3.2.0",

View File

@ -180,7 +180,7 @@ function runApp() {
/** /**
* Initial window options * Initial window options
*/ */
const newWindow = new BrowserWindow({ const commonBrowserWindowOptions = {
backgroundColor: '#212121', backgroundColor: '#212121',
icon: isDev icon: isDev
? path.join(__dirname, '../../_icons/iconColor.png') ? path.join(__dirname, '../../_icons/iconColor.png')
@ -194,10 +194,36 @@ function runApp() {
webSecurity: false, webSecurity: false,
backgroundThrottling: false, backgroundThrottling: false,
contextIsolation: false contextIsolation: false
}, }
show: false }
const newWindow = new BrowserWindow(
Object.assign(
{
// It will be shown later when ready via `ready-to-show` event
show: false
},
commonBrowserWindowOptions
)
)
// region Ensure child windows use same options since electron 14
// https://github.com/electron/electron/blob/14-x-y/docs/api/window-open.md#native-window-example
newWindow.webContents.setWindowOpenHandler(() => {
return {
action: 'allow',
overrideBrowserWindowOptions: Object.assign(
{
// It should be visible on click
show: true
},
commonBrowserWindowOptions
)
}
}) })
// endregion Ensure child windows use same options since electron 14
if (replaceMainWindow) { if (replaceMainWindow) {
mainWindow = newWindow mainWindow = newWindow
} }

View File

@ -937,7 +937,7 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d"
integrity sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g== integrity sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g==
"@electron/get@^1.0.1": "@electron/get@^1.13.0":
version "1.13.0" version "1.13.0"
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.13.0.tgz#95c6bcaff4f9a505ea46792424f451efea89228c" resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.13.0.tgz#95c6bcaff4f9a505ea46792424f451efea89228c"
integrity sha512-+SjZhRuRo+STTO1Fdhzqnv9D2ZhjxXP6egsJ9kiO8dtP68cDx7dFCwWi64dlMQV7sWcfW1OYCW4wviEBzmRsfQ== integrity sha512-+SjZhRuRo+STTO1Fdhzqnv9D2ZhjxXP6egsJ9kiO8dtP68cDx7dFCwWi64dlMQV7sWcfW1OYCW4wviEBzmRsfQ==
@ -3543,12 +3543,12 @@ electron-to-chromium@^1.3.830:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.836.tgz#823cb9c98f28c64c673920f1c90ea3826596eaf9" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.836.tgz#823cb9c98f28c64c673920f1c90ea3826596eaf9"
integrity sha512-Ney3pHOJBWkG/AqYjrW0hr2AUCsao+2uvq9HUlRP8OlpSdk/zOHOUJP7eu0icDvePC9DlgffuelP4TnOJmMRUg== integrity sha512-Ney3pHOJBWkG/AqYjrW0hr2AUCsao+2uvq9HUlRP8OlpSdk/zOHOUJP7eu0icDvePC9DlgffuelP4TnOJmMRUg==
electron@^13.5.1: electron@^15.3.1:
version "13.5.1" version "15.3.1"
resolved "https://registry.yarnpkg.com/electron/-/electron-13.5.1.tgz#76c02c39be228532f886a170b472cbd3d93f0d0f" resolved "https://registry.yarnpkg.com/electron/-/electron-15.3.1.tgz#38ce9dfcd4ec51a33d62de23de15fb5ceeaea25d"
integrity sha512-ZyxhIhmdaeE3xiIGObf0zqEyCyuIDqZQBv9NKX8w5FNzGm87j4qR0H1+GQg6vz+cA1Nnv1x175Zvimzc0/UwEQ== integrity sha512-6/qp3Dor7HSGq28qhJEVD1zBFZoWicmo3/ZLvo7rhXPPZFwEMSJGPMEZM9WYSfWW4t/OozpWNuuDe970cF7g2Q==
dependencies: dependencies:
"@electron/get" "^1.0.1" "@electron/get" "^1.13.0"
"@types/node" "^14.6.2" "@types/node" "^14.6.2"
extract-zip "^1.0.3" extract-zip "^1.0.3"