Skip to content

Commit

Permalink
Auto update test
Browse files Browse the repository at this point in the history
  • Loading branch information
PatentLobster committed Jul 23, 2021
1 parent 53ec79b commit abde215
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stinker",
"version": "0.1.8",
"version": "0.1.9",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
10 changes: 10 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ export default {
this.$router.push('/tinker');
})
ipcRenderer.on('update-available', () => {
console.log('update available');
ipcRenderer.send('download-update');
});
ipcRenderer.on('update-downloaded', () => {
console.log('update-downloaded');
ipcRenderer.send('install-update');
});
}
}
Expand Down
24 changes: 22 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('@electron/remote/main').initialize()
const Store = require('electron-store');
Store.initRenderer()
import { autoUpdater } from "electron-updater";

let win;
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
Expand All @@ -25,7 +25,27 @@ ipcMain.on('app_loaded', (event, arg) => {
event.reply('asynchronous-reply', argv)
})

let win;
ipcMain.on('updater-ready', () => {
autoUpdater.checkForUpdates()
})

autoUpdater.on('update-available', () => {
win.webContents.send('update-available');
})

ipcMain.on('download-update', () => {
autoUpdater.downloadUpdate()
})

autoUpdater.on('update-downloaded', () => {
win.webContents.send('update-downloaded');
})

ipcMain.on('install-update', () => {
autoUpdater.quitAndInstall()
})


async function createWindow() {
// Create the browser window.
win = new BrowserWindow({
Expand Down

0 comments on commit abde215

Please sign in to comment.