Fix devtools shortcuts in packaged app
This commit is contained in:
+21
-2
@@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, globalShortcut, ipcMain, screen } from 'electron'
|
||||
import { app, BrowserWindow, Menu, globalShortcut, ipcMain, screen } from 'electron'
|
||||
import type { WebContents } from 'electron'
|
||||
import { spawn, type ChildProcessWithoutNullStreams } from 'child_process'
|
||||
import { createWriteStream, existsSync } from 'fs'
|
||||
@@ -3111,8 +3111,10 @@ if (process.platform === 'linux' && !is.dev) {
|
||||
|
||||
function attachDevToolsShortcut(win: BrowserWindow): void {
|
||||
win.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.type !== 'keyDown') return
|
||||
const key = input.key.toLowerCase()
|
||||
if (input.key === 'F12' || (input.control && input.shift && key === 'i')) {
|
||||
const code = input.code.toLowerCase()
|
||||
if (input.key === 'F12' || code === 'f12' || ((input.control || input.meta) && input.shift && key === 'i')) {
|
||||
event.preventDefault()
|
||||
win.webContents.toggleDevTools()
|
||||
}
|
||||
@@ -3138,6 +3140,23 @@ function toggleFocusedDevTools(): void {
|
||||
function registerDevToolsShortcuts(): void {
|
||||
globalShortcut.register('CommandOrControl+Shift+I', toggleFocusedDevTools)
|
||||
globalShortcut.register('F12', toggleFocusedDevTools)
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: 'F12',
|
||||
click: toggleFocusedDevTools
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: 'CommandOrControl+Shift+I',
|
||||
click: toggleFocusedDevTools
|
||||
}
|
||||
]
|
||||
}
|
||||
]))
|
||||
}
|
||||
|
||||
function createSplashWindow(): void {
|
||||
|
||||
Reference in New Issue
Block a user