mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-02-07 17:00:10 +08:00
feature: 在应用未打包时自动打开 devTools
This commit is contained in:
parent
858ea14cfa
commit
aec9a41f66
@ -2,6 +2,8 @@ import { app, BrowserWindow, shell, ipcMain } from 'electron'
|
|||||||
import { release } from 'os'
|
import { release } from 'os'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
|
||||||
|
const { isPackaged } = app
|
||||||
|
|
||||||
// Disable GPU Acceleration for Windows 7
|
// Disable GPU Acceleration for Windows 7
|
||||||
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
|
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
|
||||||
|
|
||||||
@ -46,13 +48,16 @@ async function createWindow() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (app.isPackaged) {
|
if (isPackaged) {
|
||||||
win.loadFile(indexHtml)
|
win.loadFile(indexHtml)
|
||||||
} else {
|
} else {
|
||||||
win.loadURL(url)
|
win.loadURL(url)
|
||||||
// win.webContents.openDevTools()
|
// win.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open devTool if the app is not packaged
|
||||||
|
!isPackaged && win.webContents.openDevTools()
|
||||||
|
|
||||||
// Test actively push message to the Electron-Renderer
|
// Test actively push message to the Electron-Renderer
|
||||||
win.webContents.on('did-finish-load', () => {
|
win.webContents.on('did-finish-load', () => {
|
||||||
win?.webContents.send('main-process-message', new Date().toLocaleString())
|
win?.webContents.send('main-process-message', new Date().toLocaleString())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user