1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

init menu after app ready

This commit is contained in:
Kyle Spearrin 2018-02-10 11:58:14 -05:00
parent 214d8f7ae8
commit 884eefd589
4 changed files with 39 additions and 33 deletions

View File

@ -8,7 +8,7 @@
"build:main": "webpack --config webpack.main.js", "build:main": "webpack --config webpack.main.js",
"build:renderer": "webpack --config webpack.renderer.js", "build:renderer": "webpack --config webpack.renderer.js",
"build:renderer:watch": "webpack --config webpack.renderer.js --watch", "build:renderer:watch": "webpack --config webpack.renderer.js --watch",
"electron": "(npm run build:main | npm run build:renderer) & (electron ./build --dev --watch | npm run build:renderer:watch)" "electron": "(npm run build:main | npm run build:renderer) && (electron ./build --dev --watch | npm run build:renderer:watch)"
}, },
"devDependencies": { "devDependencies": {
"@bitwarden/jslib": "git+https://github.com/bitwarden/jslib.git", "@bitwarden/jslib": "git+https://github.com/bitwarden/jslib.git",

View File

@ -19,10 +19,10 @@ const windowMain = new WindowMain(dev);
const messagingMain = new MessagingMain(windowMain); const messagingMain = new MessagingMain(windowMain);
const menuMain = new MenuMain(windowMain, i18nService); const menuMain = new MenuMain(windowMain, i18nService);
windowMain.init(); windowMain.init().then(() => {
messagingMain.init(); messagingMain.init();
return i18nService.init();
i18nService.init().then(() => { }).then(() => {
menuMain.init(); menuMain.init();
}, (e: any) => { }, (e: any) => {
console.log(e); console.log(e);

View File

@ -329,7 +329,7 @@ export class MenuMain {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
template[0].label = app.getName(); template[0].label = app.getName();
(template[0].submenu as MenuItemConstructorOptions[]).concat([ template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat([
{ type: 'separator' }, { type: 'separator' },
{ role: 'about' }, { role: 'about' },
{ type: 'separator' }, { type: 'separator' },

View File

@ -7,34 +7,40 @@ export class WindowMain {
constructor(private dev: boolean) { } constructor(private dev: boolean) { }
init() { init(): Promise<any> {
try { return new Promise((resolve, reject) => {
// This method will be called when Electron has finished try {
// initialization and is ready to create browser windows. // This method will be called when Electron has finished
// Some APIs can only be used after this event occurs. // initialization and is ready to create browser windows.
app.on('ready', () => this.createWindow()); // Some APIs can only be used after this event occurs.
app.on('ready', () => {
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X 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();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (this.win === null) {
this.createWindow(); this.createWindow();
} resolve();
}); });
} catch (e) { // Quit when all windows are closed.
// Catch Error app.on('window-all-closed', () => {
// throw e; // On OS X 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();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (this.win === null) {
this.createWindow();
}
});
} catch (e) {
// Catch Error
// throw e;
reject(e);
}
});
} }
private createWindow() { private createWindow() {