add preload.js

This commit is contained in:
hocili
2021-03-10 18:01:42 +08:00
parent da802dd8fb
commit f8bc0cdb6a
4 changed files with 33 additions and 6 deletions

View File

@@ -1,16 +1,19 @@
import { app, BrowserWindow } from 'electron'
import {join} from "path";
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
preload: join(__dirname, 'preload.js')
}
})
if (process.env.NODE_ENV === 'development') {
win.loadURL('http://localhost:3000/')
win.webContents.openDevTools()
} else {
win.loadFile('dist/render/index.html')
}