Skip to content

Commit cbf95cc

Browse files
committed
fix devtools permission error
1 parent 1582e58 commit cbf95cc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

template/src/main/BrowserWinHandler.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ export default class BrowserWinHandler {
2222
// This method will be called when Electron has finished
2323
// initialization and is ready to create browser windows.
2424
// Some APIs can only be used after this event occurs.
25-
app.on('ready', () => {
26-
this._create()
27-
})
25+
if (app.isReady()) this._create()
26+
else {
27+
app.once('ready', () => {
28+
this._create()
29+
})
30+
}
2831

2932
// On macOS it's common to re-create a window in the app when the
3033
// dock icon is clicked and there are no other windows open.
@@ -68,7 +71,6 @@ export default class BrowserWinHandler {
6871
if (this.browserWindow !== null) return callback(this.browserWindow);
6972
this._eventEmitter.once('created', () => {
7073
callback(this.browserWindow)
71-
if (isDev && BrowserWindow.getAllWindows().length === 1) this.browserWindow.webContents.openDevTools()
7274
})
7375
}
7476

template/src/main/boot/index.dev.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer';
44
import { ELECTRON_RELAUNCH_CODE } from '../../../.electron-nuxt/config'
55
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
66

7+
app.once('browser-window-created', (_, browserWindow) => {
8+
browserWindow.webContents.once('did-frame-finish-load', () => {
9+
browserWindow.webContents.openDevTools();
10+
})
11+
})
712

813
app.on('ready', () => {
914
const menu = Menu.getApplicationMenu()

0 commit comments

Comments
 (0)