mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-28 12:35:40 +01:00
updater and about information in menu
This commit is contained in:
parent
3ee71a2b5b
commit
3d2a53bdde
@ -113,10 +113,11 @@
|
|||||||
"@angular/upgrade": "5.2.0",
|
"@angular/upgrade": "5.2.0",
|
||||||
"angular2-toaster": "4.0.2",
|
"angular2-toaster": "4.0.2",
|
||||||
"angulartics2": "5.0.1",
|
"angulartics2": "5.0.1",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "2.4.1",
|
||||||
"desktop-idle": "1.1.1",
|
"desktop-idle": "1.1.1",
|
||||||
"keytar": "^4.1.0",
|
"electron-updater": "2.20.1",
|
||||||
"rxjs": "^5.5.6",
|
"keytar": "4.1.0",
|
||||||
"zone.js": "^0.8.19"
|
"rxjs": "5.5.6",
|
||||||
|
"zone.js": "0.8.19"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -750,5 +750,24 @@
|
|||||||
},
|
},
|
||||||
"disableFaviconDesc": {
|
"disableFaviconDesc": {
|
||||||
"message": "Website Icons provide a recognizable image next to each login item in your vault."
|
"message": "Website Icons provide a recognizable image next to each login item in your vault."
|
||||||
|
},
|
||||||
|
"about": {
|
||||||
|
"message": "About"
|
||||||
|
},
|
||||||
|
"copy": {
|
||||||
|
"message": "Copy",
|
||||||
|
"description": "Copy to clipboard"
|
||||||
|
},
|
||||||
|
"checkForUpdates": {
|
||||||
|
"message": "Check For Updates"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"message": "Version $VERSION_NUM$",
|
||||||
|
"placeholders": {
|
||||||
|
"version_num": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "1.2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { BrowserWindow } from 'electron';
|
|||||||
import { MenuMain } from './main/menu.main';
|
import { MenuMain } from './main/menu.main';
|
||||||
import { MessagingMain } from './main/messaging.main';
|
import { MessagingMain } from './main/messaging.main';
|
||||||
import { PowerMonitorMain } from './main/powerMonitor.main';
|
import { PowerMonitorMain } from './main/powerMonitor.main';
|
||||||
|
import { UpdaterMain } from './main/updater.main';
|
||||||
import { WindowMain } from './main/window.main';
|
import { WindowMain } from './main/window.main';
|
||||||
|
|
||||||
import { DesktopMainMessagingService } from './services/desktopMainMessaging.service';
|
import { DesktopMainMessagingService } from './services/desktopMainMessaging.service';
|
||||||
@ -25,7 +26,8 @@ const i18nService = new I18nService('en', './locales/');
|
|||||||
const storageService = new DesktopStorageService();
|
const storageService = new DesktopStorageService();
|
||||||
const messagingService = new DesktopMainMessagingService(windowMain, messagingMain);
|
const messagingService = new DesktopMainMessagingService(windowMain, messagingMain);
|
||||||
|
|
||||||
const menuMain = new MenuMain(windowMain, i18nService, messagingService);
|
const updaterMain = new UpdaterMain();
|
||||||
|
const menuMain = new MenuMain(windowMain, updaterMain, i18nService, messagingService);
|
||||||
const powerMonitorMain = new PowerMonitorMain(storageService, messagingService);
|
const powerMonitorMain = new PowerMonitorMain(storageService, messagingService);
|
||||||
|
|
||||||
windowMain.init().then(() => {
|
windowMain.init().then(() => {
|
||||||
@ -34,6 +36,7 @@ windowMain.init().then(() => {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
menuMain.init();
|
menuMain.init();
|
||||||
powerMonitorMain.init();
|
powerMonitorMain.init();
|
||||||
|
updaterMain.init();
|
||||||
}, (e: any) => {
|
}, (e: any) => {
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
app,
|
app,
|
||||||
BrowserWindow,
|
BrowserWindow,
|
||||||
|
clipboard,
|
||||||
dialog,
|
dialog,
|
||||||
ipcMain,
|
ipcMain,
|
||||||
Menu,
|
Menu,
|
||||||
@ -8,14 +9,15 @@ import {
|
|||||||
shell,
|
shell,
|
||||||
} from 'electron';
|
} from 'electron';
|
||||||
|
|
||||||
|
import { UpdaterMain } from './updater.main';
|
||||||
import { WindowMain } from './window.main';
|
import { WindowMain } from './window.main';
|
||||||
|
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
|
|
||||||
export class MenuMain {
|
export class MenuMain {
|
||||||
constructor(private windowMain: WindowMain, private i18nService: I18nService,
|
constructor(private windowMain: WindowMain, private updaterMain: UpdaterMain,
|
||||||
private messagingService: MessagingService) { }
|
private i18nService: I18nService, private messagingService: MessagingService) { }
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
const template: MenuItemConstructorOptions[] = [
|
const template: MenuItemConstructorOptions[] = [
|
||||||
@ -306,6 +308,10 @@ export class MenuMain {
|
|||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
const firstMenuPart: MenuItemConstructorOptions[] = [
|
const firstMenuPart: MenuItemConstructorOptions[] = [
|
||||||
{ role: 'about' },
|
{ role: 'about' },
|
||||||
|
{
|
||||||
|
label: this.i18nService.t('checkForUpdates'),
|
||||||
|
click: () => this.updaterMain.checkForUpdate(),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
template.unshift({
|
template.unshift({
|
||||||
@ -331,8 +337,40 @@ export class MenuMain {
|
|||||||
{ role: 'front' },
|
{ role: 'front' },
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
|
// File menu
|
||||||
template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat(
|
template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat(
|
||||||
firstMenuOptions);
|
firstMenuOptions);
|
||||||
|
|
||||||
|
// About menu
|
||||||
|
template[template.length - 1].submenu =
|
||||||
|
(template[template.length - 1].submenu as MenuItemConstructorOptions[]).concat([
|
||||||
|
{ type: 'separator' },
|
||||||
|
{
|
||||||
|
label: this.i18nService.t('checkForUpdates'),
|
||||||
|
click: () => this.updaterMain.checkForUpdate(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.i18nService.t('about'),
|
||||||
|
click: () => {
|
||||||
|
const aboutInformation = this.i18nService.t('version', app.getVersion()) +
|
||||||
|
'\nShell ' + process.versions['electron'] +
|
||||||
|
'\nRenderer ' + process.versions['chrome'] +
|
||||||
|
'\nNode ' + process.versions['node'] +
|
||||||
|
'\nArchitecture ' + process.arch;
|
||||||
|
const result = dialog.showMessageBox(this.windowMain.win, {
|
||||||
|
title: 'Bitwarden',
|
||||||
|
message: 'Bitwarden',
|
||||||
|
detail: aboutInformation,
|
||||||
|
type: 'info',
|
||||||
|
noLink: true,
|
||||||
|
buttons: [this.i18nService.t('ok'), this.i18nService.t('copy')],
|
||||||
|
});
|
||||||
|
if (result === 1) {
|
||||||
|
clipboard.writeText(aboutInformation);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
|
15
src/main/updater.main.ts
Normal file
15
src/main/updater.main.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { autoUpdater } from "electron-updater"
|
||||||
|
|
||||||
|
const UpdaterCheckInitalDelay = 5 * 1000; // 5 seconds
|
||||||
|
const UpdaterCheckInterval = 12 * 60 * 60 * 1000; // 12 hours
|
||||||
|
|
||||||
|
export class UpdaterMain {
|
||||||
|
async init() {
|
||||||
|
global.setTimeout(async () => await this.checkForUpdate(), UpdaterCheckInitalDelay);
|
||||||
|
global.setInterval(async () => await this.checkForUpdate(), UpdaterCheckInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkForUpdate() {
|
||||||
|
return await autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user