Skip to content

Instantly share code, notes, and snippets.

@Downes Downes/bootstrap.js
Created Jan 13, 2019

Embed
What would you like to do?
Electron sample boostrap..js file
// console.log('testing')
const{app,BrowserWindow, Menu} = require('electron')
const ipc = require('electron').ipcMain
// main process
const path = require('path')
const url = require('url')
require('electron-reload')(__dirname)
let win
ipc.on('reply', (event,message) => {
console.log(event,message)
win.webContents.send('Message from bootstrap.js', 'Message from window 2: ${message}')
})
function createWindow() {
win = new BrowserWindow({width:800,height:600})
win.loadURL(url.format({
pathname:path.join(__dirname, 'src/main.html'),
protocol: 'file',
slashes:true
}))
win.on('closed',() => {
win = null
})
win.openDevTools()
var menu = Menu.buildFromTemplate([
{
label:'Electron',submenu:[
{label:'Preferences'},
{type:'separator'},
{label:'log',click() { console.log('log item clicked')} }
]
}
])
Menu.setApplicationMenu(menu)
}
app.on('ready', createWindow)
app.on('wondow-all-closed', ()=>{
app.quit()
/* if(process.platform !== 'darwin') {
app.quit()
} */
})
app.on('activate', () => {
if (win == null){
createWindow()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.