2021-03-09 14:59:24 +08:00
|
|
|
import { app, BrowserWindow } from 'electron'
|
2021-03-10 18:01:42 +08:00
|
|
|
import {join} from "path";
|
2021-03-09 14:59:24 +08:00
|
|
|
|
|
|
|
|
function createWindow() {
|
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
|
width: 800,
|
|
|
|
|
height: 600,
|
|
|
|
|
webPreferences: {
|
2021-03-10 18:01:42 +08:00
|
|
|
nodeIntegration: true,
|
|
|
|
|
preload: join(__dirname, 'preload.js')
|
2021-03-09 14:59:24 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
win.loadURL('http://localhost:3000/')
|
2021-03-10 18:01:42 +08:00
|
|
|
win.webContents.openDevTools()
|
2021-03-09 14:59:24 +08:00
|
|
|
} else {
|
|
|
|
|
win.loadFile('dist/render/index.html')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.whenReady().then(createWindow)
|
|
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
|
app.quit()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
|
|
createWindow()
|
|
|
|
|
}
|
|
|
|
|
})
|