|
@@ -2,13 +2,9 @@
|
|
|
const {app, BrowserWindow} = require('electron')
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
const path = require('path')
|
|
const path = require('path')
|
|
|
|
|
|
|
|
-// Keep a global reference of the window object, if you don't, the window will
|
|
|
|
|
-// be closed automatically when the JavaScript object is garbage collected.
|
|
|
|
|
-let mainWindow
|
|
|
|
|
-
|
|
|
|
|
function createWindow () {
|
|
function createWindow () {
|
|
|
// Create the browser window.
|
|
// Create the browser window.
|
|
|
- mainWindow = new BrowserWindow({
|
|
|
|
|
|
|
+ const mainWindow = new BrowserWindow({
|
|
|
width: 800,
|
|
width: 800,
|
|
|
height: 600,
|
|
height: 600,
|
|
|
webPreferences: {
|
|
webPreferences: {
|
|
@@ -21,14 +17,6 @@ function createWindow () {
|
|
|
|
|
|
|
|
// Open the DevTools.
|
|
// Open the DevTools.
|
|
|
// mainWindow.webContents.openDevTools()
|
|
// mainWindow.webContents.openDevTools()
|
|
|
-
|
|
|
|
|
- // Emitted when the window is closed.
|
|
|
|
|
- mainWindow.on('closed', function () {
|
|
|
|
|
- // Dereference the window object, usually you would store windows
|
|
|
|
|
- // in an array if your app supports multi windows, this is the time
|
|
|
|
|
- // when you should delete the corresponding element.
|
|
|
|
|
- mainWindow = null
|
|
|
|
|
- })
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// This method will be called when Electron has finished
|
|
// This method will be called when Electron has finished
|
|
@@ -46,7 +34,7 @@ app.on('window-all-closed', function () {
|
|
|
app.on('activate', function () {
|
|
app.on('activate', function () {
|
|
|
// On macOS it's common to re-create a window in the app when the
|
|
// On macOS it's common to re-create a window in the app when the
|
|
|
// dock icon is clicked and there are no other windows open.
|
|
// dock icon is clicked and there are no other windows open.
|
|
|
- if (mainWindow === null) createWindow()
|
|
|
|
|
|
|
+ if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// In this file you can include the rest of your app's specific main process
|
|
// In this file you can include the rest of your app's specific main process
|