feature: 在应用未打包时自动打开 devTools

This commit is contained in:
SaberAlter 2022-07-27 00:05:20 +08:00
parent 858ea14cfa
commit aec9a41f66

View File

@ -2,6 +2,8 @@ import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'os'
import { join } from 'path'
const { isPackaged } = app
// Disable GPU Acceleration for Windows 7
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
@ -46,13 +48,16 @@ async function createWindow() {
},
})
if (app.isPackaged) {
if (isPackaged) {
win.loadFile(indexHtml)
} else {
win.loadURL(url)
// win.webContents.openDevTools()
}
// Open devTool if the app is not packaged
!isPackaged && win.webContents.openDevTools()
// Test actively push message to the Electron-Renderer
win.webContents.on('did-finish-load', () => {
win?.webContents.send('main-process-message', new Date().toLocaleString())