Prototype updater window

This commit is contained in:
Yuya Ochiai
2017-08-12 00:25:58 +09:00
parent 7cc74737fe
commit 7e99059fba
8 changed files with 163 additions and 0 deletions

44
src/main/autoUpdater.js Normal file
View File

@@ -0,0 +1,44 @@
const {app, BrowserWindow, ipcMain} = require('electron');
function setEvent(win, eventName) {
ipcMain.on(eventName, (event) => {
if (event.sender === win.webContents) {
win.emit(eventName);
}
});
}
function createUpdaterWindow(options) {
const windowWidth = 480;
const windowHeight = 240;
const windowOptions = {
title: `${app.getName()} Updater`,
maximizable: false,
show: false,
width: windowWidth,
height: windowHeight,
resizable: false,
autoHideMenuBar: true
};
if (process.platform === 'linux') {
windowOptions.icon = options.linuxAppIcon;
}
const win = new BrowserWindow(windowOptions);
win.once('ready-to-show', () => {
win.show();
});
const updaterURL = (global.isDev ? 'http://localhost:8080' : `file://${app.getAppPath()}`) + '/browser/updater.html';
win.loadURL(updaterURL);
setEvent(win, 'click-release-notes');
setEvent(win, 'click-skip');
setEvent(win, 'click-remind');
setEvent(win, 'click-install');
return win;
}
module.exports = {
createUpdaterWindow
};