rhysd / electron-about-window

'About This App' mini-window for Electron apps
https://www.npmjs.com/package/about-window
MIT License
413 stars 45 forks source link

About window broken in Electron 5 #37

Closed dtslvr closed 5 years ago

dtslvr commented 5 years ago

I have upgraded to Electron 5.0.1 and located that the about window is broken. There is no text anymore, just the (broken) icon with a "App icon" label".

Vages commented 5 years ago

Same here. Here's how it looks.

image
Vages commented 5 years ago

I found a fix. Will be posting a PR in a few minutes.

Vages commented 5 years ago

While the PR is waiting to be merged, you can use patch-package and add the following file to your project's patches folder. Name the file about-window+1.12.1.patch (or change the version number if you're on some earlier version):

diff --git a/node_modules/about-window/src/index.js b/node_modules/about-window/src/index.js
index 6a3cb6f..7bc8545 100644
--- a/node_modules/about-window/src/index.js
+++ b/node_modules/about-window/src/index.js
@@ -100,6 +100,11 @@ function openAboutWindow(info_or_img_path) {
         titleBarStyle: 'hidden-inset',
         show: !info.adjust_window_size,
         icon: info.icon_path,
+        webPreferences: {
+            // For security reasons, nodeIntegration is no longer true by default when using Electron v5 or later
+            // nodeIntegration can be safely enabled as long as the window source is not remote
+            nodeIntegration: true,
+        },
     }, info.win_options || {});
     window = new (electron_1.BrowserWindow || electron_1.remote.BrowserWindow)(options);
     window.once('closed', () => {
4rno commented 5 years ago

Thanks @Vages ! On my side, I'm gonna use your fork repo while we wait your PR to be merged.

4rno commented 5 years ago

Actually, you can also use the win_options property when you call the openAboutWindow() function, and set nodeIntegration to true.

openAboutWindow({
    ...
    win_options: {
        webPreferences: {
            nodeIntegration: true
        }
    }
})

win_options | Options of 'About This App' window. It is merged into default options. Optional | BrowserWindow options object

rhysd commented 5 years ago

This issue was fixed by v1.13.0. Please update package.

dtslvr commented 5 years ago

This issue was fixed by v1.13.0. Please update package.

Thanks a lot, @rhysd and @Vages!