Electron: Allow to open DevTools from context menu (#4206)
This commit is contained in:
parent
4987c40e7d
commit
8548e96e01
@ -5,7 +5,7 @@ import contextMenu from 'electron-context-menu';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { initDeeplink } from './deeplink';
|
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';
|
import { createWindow, setupCloseHandlers, setupElectronActionHandlers } from './window';
|
||||||
|
|
||||||
initDeeplink();
|
initDeeplink();
|
||||||
@ -16,6 +16,7 @@ contextMenu({
|
|||||||
showSearchWithGoogle: false,
|
showSearchWithGoogle: false,
|
||||||
showCopyImage: false,
|
showCopyImage: false,
|
||||||
showSelectAll: true,
|
showSelectAll: true,
|
||||||
|
showInspectElement: !IS_PRODUCTION,
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export const IS_WINDOWS = process.platform === 'win32';
|
|||||||
export const IS_LINUX = process.platform === 'linux';
|
export const IS_LINUX = process.platform === 'linux';
|
||||||
export const IS_PREVIEW = process.env.IS_PREVIEW === 'true';
|
export const IS_PREVIEW = process.env.IS_PREVIEW === 'true';
|
||||||
export const IS_FIRST_RUN = !fs.existsSync(`${app.getPath('userData')}/config.json`);
|
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 windows = new Set<BrowserWindow>();
|
||||||
export const store: Store = new Store();
|
export const store: Store = new Store();
|
||||||
|
|||||||
@ -12,8 +12,9 @@ import { processDeeplink } from './deeplink';
|
|||||||
import { captureLocalStorage, restoreLocalStorage } from './localStorage';
|
import { captureLocalStorage, restoreLocalStorage } from './localStorage';
|
||||||
import tray from './tray';
|
import tray from './tray';
|
||||||
import {
|
import {
|
||||||
checkIsWebContentsUrlAllowed, forceQuit, getAppTitle, getCurrentWindow, getLastWindow, hasExtraWindows,
|
checkIsWebContentsUrlAllowed, forceQuit, getAppTitle, getCurrentWindow, getLastWindow,
|
||||||
IS_FIRST_RUN, IS_MAC_OS, IS_PREVIEW, IS_WINDOWS, reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
|
hasExtraWindows, IS_FIRST_RUN, IS_MAC_OS, IS_PREVIEW, IS_PRODUCTION, IS_WINDOWS,
|
||||||
|
reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import windowStateKeeper from './windowState';
|
import windowStateKeeper from './windowState';
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ export function createWindow(url?: string) {
|
|||||||
title: getAppTitle(),
|
title: getAppTitle(),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
devTools: process.env.APP_ENV !== 'production',
|
devTools: !IS_PRODUCTION,
|
||||||
},
|
},
|
||||||
...(IS_MAC_OS && {
|
...(IS_MAC_OS && {
|
||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
@ -127,7 +128,7 @@ export function createWindow(url?: string) {
|
|||||||
window.webContents.once('dom-ready', async () => {
|
window.webContents.once('dom-ready', async () => {
|
||||||
processDeeplink();
|
processDeeplink();
|
||||||
|
|
||||||
if (process.env.APP_ENV === 'production') {
|
if (IS_PRODUCTION) {
|
||||||
setupAutoUpdates(windowState);
|
setupAutoUpdates(windowState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user