|
@@ -106,19 +106,13 @@ for the application to be ready and open a window:
|
|
|
|
|
|
```javascript
|
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
-const path = require('path')
|
|
|
-const url = require('url')
|
|
|
|
|
|
function createWindow () {
|
|
|
// Create the browser window.
|
|
|
win = new BrowserWindow({width: 800, height: 600})
|
|
|
|
|
|
// and load the index.html of the app.
|
|
|
- win.loadURL(url.format({
|
|
|
- pathname: path.join(__dirname, 'index.html'),
|
|
|
- protocol: 'file:',
|
|
|
- slashes: true
|
|
|
- }))
|
|
|
+ win.loadFile('index.html')
|
|
|
}
|
|
|
|
|
|
app.on('ready', createWindow)
|
|
@@ -131,8 +125,6 @@ windows on macOS if the user clicks on the app's icon in the dock.
|
|
|
|
|
|
```javascript
|
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
-const path = require('path')
|
|
|
-const url = require('url')
|
|
|
|
|
|
// 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.
|
|
@@ -143,11 +135,7 @@ function createWindow () {
|
|
|
win = new BrowserWindow({width: 800, height: 600})
|
|
|
|
|
|
// and load the index.html of the app.
|
|
|
- win.loadURL(url.format({
|
|
|
- pathname: path.join(__dirname, 'index.html'),
|
|
|
- protocol: 'file:',
|
|
|
- slashes: true
|
|
|
- }))
|
|
|
+ win.loadFile('index.html')
|
|
|
|
|
|
// Open the DevTools.
|
|
|
win.webContents.openDevTools()
|