-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
doviettung96
committed
Jun 26, 2017
1 parent
0af3816
commit 26a117c
Showing
3 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* updater.js | ||
* | ||
* Please use manual update only when it is really required, otherwise please use recommended non-intrusive auto update. | ||
* | ||
* Import steps: | ||
* 1. create `updater.js` for the code snippet | ||
* 2. require `updater.js` for menu implementation, and set `checkForUpdates` callback from `updater` for the click property of `Check Updates...` MenuItem. | ||
*/ | ||
const dialog = require('electron').dialog; | ||
const autoUpdater = require('electron-updater').autoUpdater; | ||
|
||
autoUpdater.autoDownload = false | ||
|
||
autoUpdater.on('error', (event, error) => { | ||
dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) | ||
}) | ||
|
||
autoUpdater.on('update-available', () => { | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Found Updates', | ||
message: 'Found updates, do you want update now?', | ||
buttons: ['Sure', 'No'] | ||
}, (buttonIndex) => { | ||
if (buttonIndex === 0) { | ||
autoUpdater.downloadUpdate() | ||
} | ||
}) | ||
}) | ||
|
||
autoUpdater.on('update-not-available', () => { | ||
dialog.showMessageBox({ | ||
title: 'No Updates', | ||
message: 'Current version is up-to-date.' | ||
}) | ||
}) | ||
|
||
autoUpdater.on('update-downloaded', () => { | ||
dialog.showMessageBox({ | ||
title: 'Install Updates', | ||
message: 'Updates downloaded, application will be quit for update...' | ||
}, () => { | ||
autoUpdater.quitAndInstall() | ||
}) | ||
}) | ||
|
||
// export this to MenuItem click callback | ||
function checkForUpdates () { | ||
autoUpdater.checkForUpdates() | ||
} | ||
module.exports.checkForUpdates = checkForUpdates |
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 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