Add semi-automatic update support for macOS
For fully automatic macOS updates, electron-updater requires: 1. Distributing macOS file as .zip (electron-userland/electron-builder#2199) 2. Code signing for the application privacy.sexy as of today lacks both the distribution and code signing. This commit introduces auto-updates through automatically checking for updates, downloading them but requiring user to drag application icons to Applications by opening dmg file. This commit also fixes: 1. Progress state in update progress bar not being shown. 2. Downloading updates were being triggered even though it was not desired as downloads are being handled using different based on OS and user choice. In the end it refactors the code for handling updates of two different kinds, and making message dialog use enums for results instead of response integers as well as setting default and cancel button behavior. Refactorings make behaviors more explicit and extends the control.
This commit is contained in:
@@ -9,7 +9,7 @@ import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
||||
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer';
|
||||
import path from 'path';
|
||||
import log from 'electron-log';
|
||||
import { setupAutoUpdater } from './Updater';
|
||||
import { setupAutoUpdater } from './Update/Updater';
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
declare const __static: string; // https://github.com/electron-userland/electron-webpack/issues/172
|
||||
@@ -28,7 +28,6 @@ if (!process.env.IS_TEST) {
|
||||
Object.assign(console, log.functions); // override console.log, console.warn etc.
|
||||
}
|
||||
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
const size = getWindowSize(1650, 955);
|
||||
@@ -55,15 +54,26 @@ function createWindow() {
|
||||
});
|
||||
}
|
||||
|
||||
let macOsQuit = false;
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', () => {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
if (process.platform === 'darwin'
|
||||
&& !macOsQuit) {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
return;
|
||||
}
|
||||
app.quit();
|
||||
});
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
// On macOS we application quit is stopped if user does not Cmd + Q
|
||||
// But we still want to be able to use app.quit() and quit the application on menu bar, after updates etc.
|
||||
app.on('before-quit', () => {
|
||||
macOsQuit = true;
|
||||
});
|
||||
}
|
||||
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
@@ -142,4 +152,3 @@ function getWindowSize(idealWidth: number, idealHeight: number) {
|
||||
height = Math.min(height, idealHeight);
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user