Created
October 8, 2018 17:04
-
-
Save logikinc/198be7537265de55b8a1edc1b12c5560 to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
This file contains 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> | |
<!-- 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>. | |
<script> | |
// You can also require other files to run in this process | |
require('./renderer.js') | |
</script> | |
</body> | |
</html> |
This file contains 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
// The "autoUpdater" module enables apps to automatically update themselves. | |
// | |
// For more info, see: | |
// https://electronjs.org/docs/api/auto-updater | |
const { app, autoUpdater } = require('electron') | |
app.on('ready', () => { | |
const server = 'https://your-deployment-url.com' | |
const feed = `${server}/update/${process.platform}/${app.getVersion()}` | |
// The following code won't work unless the app has been packaged. | |
// You should only use the autoUpdater with packaged and code-signed | |
// versions of your application. | |
try { | |
autoUpdater.setFeedURL(feed) | |
} catch (error) { | |
console.log(error) | |
} | |
// Once you've done that, you can go ahead and ask for updates: | |
// autoUpdater.checkForUpdates() | |
autoUpdater.on('checking-for-update', () => { | |
console.log('The autoUpdater is checking for an update') | |
}) | |
autoUpdater.on('update-available', () => { | |
console.log('The autoUpdater has found an update!') | |
}) | |
autoUpdater.on('update-available', () => { | |
console.log('The autoUpdater has found an update and is now downloading it!') | |
}) | |
autoUpdater.on('update-not-available', () => { | |
console.log('The autoUpdater has not found any updates :(') | |
}) | |
autoUpdater.on('update-downloaded', (event, notes, name, date) => { | |
console.log('The autoUpdater has downloaded an update!') | |
console.log(`The new release is named ${name} and was released on ${date}`) | |
console.log(`The release notes are: ${notes}`) | |
// The update will automatically be installed the next time the | |
// app launches. If you want to, you can force the installation | |
// now: | |
autoUpdater.quitAndInstall() | |
}) | |
}) |
This file contains 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
// This file is required by the index.html file and will | |
// be executed in the renderer process for that window. | |
// All of the Node.js APIs are available in this process. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment