diff --git a/main.js b/main.js index 36fce4e456ee80be86f2c5761ec117c442131c5b..46fc4897928c0a4cc62626344099882460282ac5 100644 --- a/main.js +++ b/main.js @@ -21,9 +21,11 @@ var client; /* Sub process for the express server */ class Lektor { constructor() { this.closed = true; + this.attached = false; isRunning({ win: 'lektord.exe', linux: 'lektord', mac: 'lektord' }).then(v => { if (v && config.content.lektord.attach) { logger.info('main', `Lektord is running! Attach to it`); + this.attached = true; } else if (v) { logger.error('error', `Lektord is running and attach mode is disable, exit!`); app.quit(); @@ -171,7 +173,11 @@ app.on('ready', () => { globalShortcut.register('F12', () => { var focused = BrowserWindow.getFocusedWindow(); if (focused) { - focused.webContents.openDevTools(); + if (!focused.isDevToolsOpened()) { + focused.webContents.openDevTools({ mode: 'detach' }); + } else { + focused.webContents.closeDevTools(); + } } }); });