15. REAL WORLD FILE STRUTURE
app
main.js
splash.html
splash.png
www
build
dist
node_modules
package-lock.json
package.json
16. MAIN.JS
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
let mainWindow
17. CREATEWINDOW
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
…
18. CREATEWINDOW
…
// Open the DevTools.
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
19. MAIN.JS
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
20. INDEX.HTML
…
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js
<script>document.write(process.versions.node) < /script>,
Chromium
<script>document.write(process.versions.chrome) < /script>,
and Electron
<script>document.write(process.versions.electron) < /script>.
…
63. Build Platforms Descriptions
--mac, -m, -o, --macos Build for macOS
--win, -w, --windows Build for Windows
--linux, -l Build for Linux
Build Architectures Descriptions
--x64 Build for x64
--ia32 Build for ia32
72. ELECTRON-UPDATER
Install electron-updater as an app dependency.
Use autoUpdater from electron-updater instead of
electron
npm i electron-updater
import { autoUpdater } from "electron-updater"