Last active
February 14, 2017 16:46
-
-
Save kyleparisi/75079bcecf4cde767360ec6c06a64c0e to your computer and use it in GitHub Desktop.
Electron starter
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
We are using node <script>document.write(process.versions.node)</script>, | |
Chrome <script>document.write(process.versions.chrome)</script>, | |
and Electron <script>document.write(process.versions.electron)</script>. | |
</body> | |
</html> |
This file contains hidden or 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
const { app, BrowserWindow } = require("electron"); | |
const path = require("path"); | |
const url = require("url"); | |
let win; | |
function createWindow() { | |
win = new BrowserWindow({ width: 800, height: 600 }); | |
win.loadURL( | |
url.format({ | |
pathname: path.join(__dirname, "index.html"), | |
protocol: "file:", | |
slashes: true | |
}) | |
); | |
win.webContents.openDevTools(); | |
win.on("closed", () => { | |
win = null; | |
}); | |
} | |
app.on("ready", createWindow); | |
app.on("window-all-closed", () => { | |
if (process.platform !== "darwin") { | |
app.quit(); | |
} | |
}); | |
app.on("activate", () => { | |
if (win === null) { | |
createWindow(); | |
} | |
}); |
This file contains hidden or 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
{ | |
"name": "your-app", | |
"version": "0.1.0", | |
"description": "A minimal Electron application", | |
"main": "main.js", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": { | |
"electron": "^1.4.15" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment