mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2024-12-22 21:52:31 -05:00
allow opening dev tools in release builds
This commit is contained in:
parent
5ce37f7510
commit
c811ade1a2
1 changed files with 29 additions and 3 deletions
|
@ -18,6 +18,22 @@ const defaultSize = {width: 1280, height: 800}; // good for MAS screenshots
|
|||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const devToolKey = ((process.platform === 'darwin') ?
|
||||
{ // macOS: command+option+i
|
||||
alt: true, // option
|
||||
control: false,
|
||||
meta: true, // command
|
||||
shift: false,
|
||||
code: 'KeyI'
|
||||
} : { // Windows: control+shift+i
|
||||
alt: false,
|
||||
control: true,
|
||||
meta: false, // Windows key
|
||||
shift: true,
|
||||
code: 'KeyI'
|
||||
}
|
||||
);
|
||||
|
||||
// global window references prevent them from being garbage-collected
|
||||
const _windows = {};
|
||||
|
||||
|
@ -156,9 +172,19 @@ const createWindow = ({search = null, url = 'index.html', ...browserWindowOption
|
|||
|
||||
webContents.session.setPermissionRequestHandler(handlePermissionRequest);
|
||||
|
||||
if (isDevelopment) {
|
||||
webContents.openDevTools({mode: 'detach', activate: true});
|
||||
}
|
||||
webContents.on('before-input-event', (event, input) => {
|
||||
if (input.code === devToolKey.code &&
|
||||
input.alt === devToolKey.alt &&
|
||||
input.control === devToolKey.control &&
|
||||
input.meta === devToolKey.meta &&
|
||||
input.shift === devToolKey.shift &&
|
||||
input.type === 'keyDown' &&
|
||||
!input.isAutoRepeat &&
|
||||
!input.isComposing) {
|
||||
event.preventDefault();
|
||||
webContents.openDevTools({mode: 'detach', activate: true});
|
||||
}
|
||||
});
|
||||
|
||||
const fullUrl = makeFullUrl(url, search);
|
||||
window.loadURL(fullUrl);
|
||||
|
|
Loading…
Reference in a new issue