diff --git a/src/main/index.js b/src/main/index.js index 700f045..412a805 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -13,10 +13,15 @@ function createMainWindow() { const window = new BrowserWindow() if (isDevelopment) { - window.webContents.openDevTools() - } - - if (isDevelopment) { + window.webContents.on('devtools-opened', () => { + window.focus() + setImmediate(() => { + window.focus() + }) + }) + window.webContents.on('did-frame-finish-load', () => { + window.webContents.openDevTools(); + }) window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`) } else { @@ -31,13 +36,6 @@ function createMainWindow() { mainWindow = null }) - window.webContents.on('devtools-opened', () => { - window.focus() - setImmediate(() => { - window.focus() - }) - }) - return window }