1 changed files with 19 additions and 26 deletions
@ -1,43 +1,36 @@ |
|||||||
'use strict'; |
'use strict'; |
||||||
const electron = require('electron'); |
const electron = require('electron'); |
||||||
|
const fs = require('fs'); |
||||||
|
const path = require('path'); |
||||||
const app = electron.app; |
const app = electron.app; |
||||||
const dialog = electron.dialog; |
const dialog = electron.dialog; |
||||||
|
|
||||||
const autoUpdater = electron.autoUpdater; |
const isDev = !fs.existsSync(path.resolve(path.dirname(process.execPath), '..', 'Update.exe')); |
||||||
|
|
||||||
const feedUrl = `https://getrambox.herokuapp.com/update/${process.platform}/${process.arch}/${app.getVersion()}`; |
const autoUpdater = electron.autoUpdater; |
||||||
|
|
||||||
autoUpdater.setFeedURL(feedUrl); |
const feedUrl = `https://getrambox.herokuapp.com/update/${process.platform}/${app.getVersion()}`; |
||||||
autoUpdater.checkForUpdates(); |
|
||||||
|
|
||||||
exports.check = win => { |
exports.check = win => { |
||||||
autoUpdater.on('update-available', function(a, b, c, d) { |
if ( isDev ) return; |
||||||
|
|
||||||
|
autoUpdater.on('update-available', function() { |
||||||
dialog.showMessageBox({ |
dialog.showMessageBox({ |
||||||
message: "There is a new version" |
message: 'New version' |
||||||
,buttons: ["OK"] |
,detail: 'There is a new version available.' |
||||||
|
,buttons: ['Ok'] |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
/* |
|
||||||
autoUpdater.on('update-not-available', function(a, b, c, d) { |
|
||||||
|
|
||||||
}); |
|
||||||
*/ |
|
||||||
autoUpdater.on('update-downloaded', function(e, releaseNotes, releaseName, releaseDate, updateURL) { |
autoUpdater.on('update-downloaded', function(e, releaseNotes, releaseName, releaseDate, updateURL) { |
||||||
var index = dialog.showMessageBox({ |
var index = dialog.showMessageBox({ |
||||||
message: "New version" |
message: 'A new update is ready to install' |
||||||
,detail: "Do you want to install the new version ("+releaseName+")?" |
,detail: 'Version ' + releaseName + ' is downloaded and will be automatically installed on Quit. Do you want to restart now?' |
||||||
,buttons: ["Yes", "No"] |
,buttons: ['Yes', 'No'] |
||||||
}); |
}); |
||||||
if (index === 0) { |
if (index === 0) autoUpdater.quitAndInstall(); |
||||||
autoUpdater.quitAndInstall(); |
|
||||||
} |
|
||||||
}); |
}); |
||||||
/* |
|
||||||
autoUpdater.on("error", function(error){ |
autoUpdater.setFeedURL(feedUrl); |
||||||
dialog.showMessageBox({ |
autoUpdater.checkForUpdates(); |
||||||
message: error.toString() |
|
||||||
,buttons: ["OK"] |
|
||||||
}); |
|
||||||
}); |
|
||||||
*/ |
|
||||||
}; |
}; |
||||||
|
Loading…
Reference in new issue