From abde21556d87a93ac5fbd6c2988610fc57dd5fee Mon Sep 17 00:00:00 2001 From: Itzik <37775846+PatentLobster@users.noreply.github.com> Date: Fri, 23 Jul 2021 13:59:43 +0300 Subject: [PATCH] Auto update test --- package.json | 2 +- src/App.vue | 10 ++++++++++ src/background.js | 24 ++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c0cd334..b0e318a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stinker", - "version": "0.1.8", + "version": "0.1.9", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/src/App.vue b/src/App.vue index 4055ce4..c1d3b0c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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'); + }); + } } diff --git a/src/background.js b/src/background.js index 4fe753a..a75be19 100644 --- a/src/background.js +++ b/src/background.js @@ -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 } } @@ -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({