Format URL passed to BrowserWindow.loadURL

This commit is contained in:
Kevin Sawicki 2016-10-31 10:32:20 -07:00
parent 85e575a55e
commit 995d109c32
1 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,8 @@ const app = electron.app
// Module to create native browser window. // Module to create native browser window.
const BrowserWindow = electron.BrowserWindow const BrowserWindow = electron.BrowserWindow
const url = require('url')
// Keep a global reference of the window object, if you don't, the window will // 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. // be closed automatically when the JavaScript object is garbage collected.
let mainWindow let mainWindow
@ -13,7 +15,11 @@ function createWindow () {
mainWindow = new BrowserWindow({width: 800, height: 600}) mainWindow = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`) mainWindow.loadURL(url.format({
pathname: __dirname + '/index.html',
protocol: 'file:',
slashes: true
}))
// Open the DevTools. // Open the DevTools.
mainWindow.webContents.openDevTools() mainWindow.webContents.openDevTools()