Electron: Allow to open DevTools from context menu (#4206)

This commit is contained in:
Alexander Zinchuk 2024-02-06 16:49:13 +01:00
parent 4987c40e7d
commit 8548e96e01
3 changed files with 8 additions and 5 deletions

View File

@ -5,7 +5,7 @@ import contextMenu from 'electron-context-menu';
import path from 'path';
import { initDeeplink } from './deeplink';
import { IS_MAC_OS, IS_WINDOWS } from './utils';
import { IS_MAC_OS, IS_PRODUCTION, IS_WINDOWS } from './utils';
import { createWindow, setupCloseHandlers, setupElectronActionHandlers } from './window';
initDeeplink();
@ -16,6 +16,7 @@ contextMenu({
showSearchWithGoogle: false,
showCopyImage: false,
showSelectAll: true,
showInspectElement: !IS_PRODUCTION,
});
app.on('ready', () => {

View File

@ -14,6 +14,7 @@ export const IS_WINDOWS = process.platform === 'win32';
export const IS_LINUX = process.platform === 'linux';
export const IS_PREVIEW = process.env.IS_PREVIEW === 'true';
export const IS_FIRST_RUN = !fs.existsSync(`${app.getPath('userData')}/config.json`);
export const IS_PRODUCTION = process.env.APP_ENV === 'production';
export const windows = new Set<BrowserWindow>();
export const store: Store = new Store();

View File

@ -12,8 +12,9 @@ import { processDeeplink } from './deeplink';
import { captureLocalStorage, restoreLocalStorage } from './localStorage';
import tray from './tray';
import {
checkIsWebContentsUrlAllowed, forceQuit, getAppTitle, getCurrentWindow, getLastWindow, hasExtraWindows,
IS_FIRST_RUN, IS_MAC_OS, IS_PREVIEW, IS_WINDOWS, reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
checkIsWebContentsUrlAllowed, forceQuit, getAppTitle, getCurrentWindow, getLastWindow,
hasExtraWindows, IS_FIRST_RUN, IS_MAC_OS, IS_PREVIEW, IS_PRODUCTION, IS_WINDOWS,
reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
} from './utils';
import windowStateKeeper from './windowState';
@ -61,7 +62,7 @@ export function createWindow(url?: string) {
title: getAppTitle(),
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
devTools: process.env.APP_ENV !== 'production',
devTools: !IS_PRODUCTION,
},
...(IS_MAC_OS && {
titleBarStyle: 'hidden',
@ -127,7 +128,7 @@ export function createWindow(url?: string) {
window.webContents.once('dom-ready', async () => {
processDeeplink();
if (process.env.APP_ENV === 'production') {
if (IS_PRODUCTION) {
setupAutoUpdates(windowState);
}