version of update window is added
This commit is contained in:
parent
41fb1b14a0
commit
464489da4e
|
@ -8,12 +8,18 @@ import {
|
|||
} from '../models/electron-update-window-options';
|
||||
|
||||
import { Channel } from '../types/channel.type';
|
||||
import { ElectronWebContentsChannel } from '@ucap-webmessenger/electron-core';
|
||||
|
||||
export class ElectronUpdateWindowService {
|
||||
private customOptions: ElectronUpdateWindowOptions;
|
||||
private browserWindow: BrowserWindow;
|
||||
private templateUrl: string;
|
||||
|
||||
versionInfo: {
|
||||
installed?: string;
|
||||
latest?: string;
|
||||
};
|
||||
|
||||
constructor(options: ElectronUpdateWindowOptions) {
|
||||
this.customOptions = {
|
||||
...DefaultElectronUpdateWindowOptions
|
||||
|
@ -60,14 +66,22 @@ export class ElectronUpdateWindowService {
|
|||
this.browserWindow.on('closed', () => {
|
||||
this.browserWindow = null;
|
||||
});
|
||||
this.browserWindow.webContents.on('did-finish-load', () => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
this.browserWindow.webContents.openDevTools();
|
||||
this.browserWindow.webContents.on(
|
||||
ElectronWebContentsChannel.DidFinishLoad,
|
||||
() => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
this.browserWindow.webContents.openDevTools();
|
||||
}
|
||||
if (!!this.customOptions.onReady) {
|
||||
this.customOptions.onReady();
|
||||
}
|
||||
|
||||
this.browserWindow.webContents.send(
|
||||
Channel.browserWindowSetContents,
|
||||
this.versionInfo
|
||||
);
|
||||
}
|
||||
if (!!this.customOptions.onReady) {
|
||||
this.customOptions.onReady();
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
ipcMain.on(Channel.acceptUpdate, this._acceptUpdateHandler.bind(this));
|
||||
ipcMain.on(Channel.denyUpdate, this._denyUpdateHandler.bind(this));
|
||||
|
|
|
@ -4,5 +4,7 @@ export enum Channel {
|
|||
cancelDownload = 'UCAP::ElectronUpdateWindow::cancelDownload',
|
||||
|
||||
downloadProcess = 'UCAP::ElectronUpdateWindow::downloadProcess',
|
||||
downloadComplete = 'UCAP::ElectronUpdateWindow::downloadComplete'
|
||||
downloadComplete = 'UCAP::ElectronUpdateWindow::downloadComplete',
|
||||
|
||||
browserWindowSetContents = 'UCAP::ElectronUpdateWindow::BrowserWindowSetContents'
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const ipc = electron.ipcRenderer;
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
const winId = electron.remote.getCurrentWindow().id;
|
||||
|
||||
function setStyle(config) {
|
||||
|
@ -90,13 +90,21 @@ function setContents(event, notificationObj) {
|
|||
let closeButton = notiDoc.getElementById('close');
|
||||
closeButton.addEventListener('click', function(event) {
|
||||
event.stopPropagation();
|
||||
ipc.send('UCAP::ElectronNotification::close', winId, notificationObj);
|
||||
ipcRenderer.send(
|
||||
'UCAP::ElectronNotification::close',
|
||||
winId,
|
||||
notificationObj
|
||||
);
|
||||
});
|
||||
|
||||
// URL
|
||||
let container = notiDoc.getElementById('container');
|
||||
container.addEventListener('click', function() {
|
||||
ipc.send('UCAP::ElectronNotification::click', winId, notificationObj);
|
||||
ipcRenderer.send(
|
||||
'UCAP::ElectronNotification::click',
|
||||
winId,
|
||||
notificationObj
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -130,9 +138,12 @@ function reset() {
|
|||
closeButton.parentNode.replaceChild(newCloseButton, closeButton);
|
||||
}
|
||||
|
||||
ipc.on('UCAP::ElectronNotification::BrowserWindowSetContents', setContents);
|
||||
ipc.on('UCAP::ElectronNotification::loadConfig', loadConfig);
|
||||
ipc.on('UCAP::ElectronNotification::reset', reset);
|
||||
ipcRenderer.on(
|
||||
'UCAP::ElectronNotification::BrowserWindowSetContents',
|
||||
setContents
|
||||
);
|
||||
ipcRenderer.on('UCAP::ElectronNotification::loadConfig', loadConfig);
|
||||
ipcRenderer.on('UCAP::ElectronNotification::reset', reset);
|
||||
|
||||
function log() {
|
||||
console.log.apply(console, arguments);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
const electron = require('electron');
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
|
||||
const updateWindowContainer = document.getElementById(
|
||||
'update-window-container'
|
||||
|
@ -40,6 +41,16 @@ downloadingCancel &&
|
|||
ipcRenderer.send('UCAP::ElectronUpdateWindow::cancelDownload');
|
||||
});
|
||||
|
||||
function setContents(event, versionInfo) {
|
||||
let updateDoc = global.window.document;
|
||||
|
||||
let latestVersion = updateDoc.getElementById('latestVersion');
|
||||
latestVersion.innerHTML = versionInfo.latest || '';
|
||||
|
||||
let installedVersion = updateDoc.getElementById('installedVersion');
|
||||
installedVersion.innerHTML = versionInfo.installed || '';
|
||||
}
|
||||
|
||||
ipcRenderer.on(
|
||||
'UCAP::ElectronUpdateWindow::downloadProcess',
|
||||
(event, ...args) => {
|
||||
|
@ -55,3 +66,5 @@ ipcRenderer.on(
|
|||
updateWindowContainer.style.transform = 'translateX(-1000px)';
|
||||
}
|
||||
);
|
||||
|
||||
ipc.on('UCAP::ElectronUpdateWindow::BrowserWindowSetContents', setContents);
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
<!--[S]버전다운로드-->
|
||||
<div id="confirmation" class="versionup popup step1">
|
||||
<header>
|
||||
<h1>DS Talk의 새로운 버전이 존재합니다.</h1>
|
||||
<h1>
|
||||
DS Talk의 새로운 버전[<span id="latestVersion"></span>]이
|
||||
존재합니다.
|
||||
</h1>
|
||||
</header>
|
||||
<!-- <a class="no-drag btn_close">
|
||||
<label class="global">닫기</label>
|
||||
|
|
|
@ -359,6 +359,10 @@ ipcMain.on(UpdaterChannel.Check, (event: IpcMainEvent, ...args: any[]) => {
|
|||
const ver = args[0];
|
||||
|
||||
if (semver.lt(app.getVersion(), ver)) {
|
||||
updateWindowService.versionInfo = {
|
||||
latest: ver,
|
||||
installed: app.getVersion()
|
||||
};
|
||||
autoUpdater
|
||||
.checkForUpdatesAndNotify()
|
||||
.then(result => {
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
"information": {
|
||||
"label": "Information",
|
||||
"version": "Version",
|
||||
"installedVersion": "Installed version",
|
||||
"installedVersion": "Current version",
|
||||
"latestVersion": "Latest version",
|
||||
"checkForUpdates": "Check for updates",
|
||||
"checkForUpdatesInProgress": "Checking for updates",
|
||||
|
|
|
@ -76,9 +76,9 @@
|
|||
"information": {
|
||||
"label": "정보",
|
||||
"version": "버전",
|
||||
"installedVersion": "설치된 버전",
|
||||
"installedVersion": "현재 버전",
|
||||
"latestVersion": "최신 버전",
|
||||
"checkForUpdates": "업데이트 확인",
|
||||
"checkForUpdates": "버전 확인",
|
||||
"checkForUpdatesInProgress": "업데이트를 확인하고 있습니다.",
|
||||
"applyUpdates": "업데이트 설치"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user