Created
May 23, 2017 07:13
-
-
Save shalkam/c1575814a62c0e6d22d8139dd1c7d414 to your computer and use it in GitHub Desktop.
Load url into electron without caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { app, BrowserWindow, Menu, shell } from 'electron'; | |
import Server from './server/server.js'; | |
let menu; | |
let template; | |
let mainWindow = null; | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') app.quit(); | |
}); | |
app.on('ready', () => { | |
Server.init(); | |
mainWindow = new BrowserWindow({ show: false, width: 1024, height: 728 }); | |
Server.on('server.loaded', port => { | |
mainWindow.loadURL(`http://localhost:${port}`, { extraHeaders: 'pragma: no-cache\n' }); | |
mainWindow.webContents.send('loaded.server', port); | |
}); | |
mainWindow.webContents.on('did-finish-load', () => { | |
mainWindow.show(); | |
mainWindow.focus(); | |
mainWindow.webContents.send('app.started'); | |
}); | |
mainWindow.on('closed', () => { | |
mainWindow = null; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment