You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
917 B
43 lines
917 B
4 weeks ago
|
const { app, BrowserWindow } = require('electron')
|
||
|
const path = require('path')
|
||
|
|
||
|
let mainWindow
|
||
|
|
||
|
function createWindow() {
|
||
|
mainWindow = new BrowserWindow({
|
||
|
width: 1200,
|
||
|
height: 800,
|
||
|
webPreferences: {
|
||
|
nodeIntegration: false,
|
||
|
contextIsolation: true,
|
||
|
enableRemoteModule: false,
|
||
|
preload: path.join(__dirname, '../preload.js')
|
||
|
}
|
||
|
})
|
||
|
|
||
|
// 开发模式下加载开发服务器
|
||
|
if (process.env.NODE_ENV === 'development') {
|
||
|
mainWindow.loadURL('http://localhost:8080')
|
||
|
mainWindow.webContents.openDevTools()
|
||
|
} else {
|
||
|
mainWindow.loadFile(path.join(__dirname, '../public/index.html'))
|
||
|
}
|
||
|
|
||
|
mainWindow.on('closed', () => {
|
||
|
mainWindow = null
|
||
|
})
|
||
|
}
|
||
|
|
||
|
app.whenReady().then(createWindow)
|
||
|
|
||
|
app.on('window-all-closed', () => {
|
||
|
if (process.platform !== 'darwin') {
|
||
|
app.quit()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
app.on('activate', () => {
|
||
|
if (mainWindow === null) {
|
||
|
createWindow()
|
||
|
}
|
||
|
})
|