Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const newWin = () => {
win = new electron.BrowserWindow({
icon: path.join(__dirname, 'static/icon.png')
})
win.maximize()
win.on('closed', () => win = null)
if (config.dev) {
// Install vue dev tool and open chrome dev tools
const { default: installExtension, VUEJS_DEVTOOLS } = require('electron-devtools-installer')
installExtension(VUEJS_DEVTOOLS.id).then(name => {
console.log(`Added Extension: ${name}`)
win.webContents.openDevTools()
}).catch(err => console.log('An error occurred: ', err))
// Wait for nuxt to build
const pollServer = () => {
http.get(_NUXT_URL_, (res) => {
if (res.statusCode === 200) { win.loadURL(_NUXT_URL_) } else { setTimeout(pollServer, 300) }
}).on('error', pollServer)
}
pollServer()
} else { return win.loadURL(_NUXT_URL_) }
}
app.on('ready', newWin)