index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | const { app, BrowserWindow, Menu, dialog } = require( 'electron' ) function createWindow(){ const w = new BrowserWindow({ width: 320, height: 480, webPreferences: { nodeIntergration: false } }) w.loadFile( 'index.html' ) } function createMenu(){ const m = [ { label: 'File' , submenu: [ { role: 'close' }, { type: 'separator' }, { label: 'Quit' , click: quitFunc } ] }, { label: 'About' , click: aboutFunc } ] const menu = Menu.buildFromTemplate(m) Menu.setApplicationMenu(menu) } function quitFunc(){ app.quit() } function aboutFunc(){ const w = BrowserWindow.getFocusedWindow() dialog.showMessageBox(w, { title: 'About this...' , message: 'Made with Electron!' , detail: 'Electron is a framework for building desktop applications using JavaScript, HTML, and CSS. ' }) } createMenu() app.whenReady().then(createWindow) |
コメント