From 5b679f2154104ae8becd570467694dc384d01cae Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:34:22 +0200 Subject: [PATCH 1/6] chore(main.ts): Add Keira3 navigation bar --- main.ts | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index 2f13e5866ea..4dd2134df8e 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, shell, screen } from 'electron'; +import { app, BrowserWindow, shell, screen, Menu, MenuItem, Accelerator } from 'electron'; import * as path from 'path'; import * as url from 'url'; @@ -41,7 +41,7 @@ function createWindow() { win.webContents.openDevTools(); } - win.on('close', function(e) { + win.on('close', function (e) { if (!process.env.RUNNING_IN_SPECTRON) { const choice = require('electron').dialog.showMessageBoxSync(this, { @@ -65,7 +65,7 @@ function createWindow() { }); // open links in the default browser - win.webContents.on('new-window', function(event, link) { + win.webContents.on('new-window', function (event, link) { event.preventDefault(); shell.openExternal(link); }); @@ -76,7 +76,114 @@ try { // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. - app.on('ready', createWindow); + app.on('ready', function () { + createWindow() + + // Navigation Top Bar + const navigation: Electron.MenuItemConstructorOptions[] = [ + { + label: app.name, + submenu: [ + { role: 'quit' }, + ] + }, + { + label: 'Edit', + submenu: [ + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + { role: 'delete' }, + { type: 'separator' }, + { role: 'selectAll' } + ] + }, + { + label: 'Window', + submenu: [ + { role: 'reload' }, + { role: 'forceReload' }, + { type: 'separator' }, + { role: 'toggleDevTools' }, + { type: 'separator' }, + { role: 'zoomIn' }, + { role: 'zoomOut' }, + { role: 'resetZoom' }, + { type: 'separator' }, + { role: 'togglefullscreen' }, + { role: 'minimize' }, + { role: 'close' } + ] + }, + { + label: 'Help', + submenu: [ + { + label: 'Keira3', + submenu: [ + { + label: 'Keira3 Repository', + click: function () { + shell.openExternal('https://github.com/AzerothCore/Keira3/') + } + }, + { + label: 'Report a Bug', + click: function () { + shell.openExternal('https://github.com/AzerothCore/Keira3/issues/new') + } + }, + ] + }, + { + label: 'AzerothCore', + submenu: [ + { + label: 'AzerothCore Repository', + click: function () { + shell.openExternal('https://github.com/AzerothCore/AzerothCore/') + } + }, + { + label: 'Report a Bug', + click: function () { + shell.openExternal('https://github.com/AzerothCore/AzerothCore/issues/new') + } + }, + ] + }, + { + label: 'Join our Discord', + click: function () { + shell.openExternal('https://discordapp.com/channels/217589275766685707/284406375495368704') + }, + } + ] + }, + ] + + const menu = Menu.buildFromTemplate(navigation) + Menu.setApplicationMenu(menu) + + // Right-Click Menu + const ctxMenu = new Menu() + ctxMenu.append(new MenuItem({ role: 'undo' })) + ctxMenu.append(new MenuItem({ role: 'redo' })) + ctxMenu.append(new MenuItem({ type: 'separator' })) + ctxMenu.append(new MenuItem({ role: 'cut' })) + ctxMenu.append(new MenuItem({ role: 'copy' })) + ctxMenu.append(new MenuItem({ role: 'paste' })) + ctxMenu.append(new MenuItem({ role: 'selectAll' })) + ctxMenu.append(new MenuItem({ type: 'separator' })) + ctxMenu.append(new MenuItem({ role: 'toggleDevTools' })) + + win.webContents.on('context-menu', function(){ + ctxMenu.popup(win) + }) + }); // Quit when all windows are closed. app.on('window-all-closed', () => { From 92b7f9cf91282ad1f7ef4257ce9ec4fe6a29f4d6 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:35:29 +0200 Subject: [PATCH 2/6] remove unused class --- main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 4dd2134df8e..49f53b784aa 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, shell, screen, Menu, MenuItem, Accelerator } from 'electron'; +import { app, BrowserWindow, shell, screen, Menu, MenuItem } from 'electron'; import * as path from 'path'; import * as url from 'url'; From 9d45e15032fa2e6b6a7f3396df5051d6429405a1 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:39:04 +0200 Subject: [PATCH 3/6] format --- main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 49f53b784aa..ca013459d77 100644 --- a/main.ts +++ b/main.ts @@ -180,7 +180,7 @@ try { ctxMenu.append(new MenuItem({ type: 'separator' })) ctxMenu.append(new MenuItem({ role: 'toggleDevTools' })) - win.webContents.on('context-menu', function(){ + win.webContents.on('context-menu', function () { ctxMenu.popup(win) }) }); From 3628f4de29cc8f0ee20d293233cf10e32b8e4ed5 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:42:17 +0200 Subject: [PATCH 4/6] rename const --- main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index ca013459d77..54250c49429 100644 --- a/main.ts +++ b/main.ts @@ -80,7 +80,7 @@ try { createWindow() // Navigation Top Bar - const navigation: Electron.MenuItemConstructorOptions[] = [ + const navMenu: Electron.MenuItemConstructorOptions[] = [ { label: app.name, submenu: [ @@ -165,7 +165,7 @@ try { }, ] - const menu = Menu.buildFromTemplate(navigation) + const menu = Menu.buildFromTemplate(navMenu) Menu.setApplicationMenu(menu) // Right-Click Menu From 7a1e5f55590357dad72ed71c4ec682b5cb1c3b25 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 14:32:35 +0200 Subject: [PATCH 5/6] add some shortcuts --- main.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 54250c49429..2aedf095dff 100644 --- a/main.ts +++ b/main.ts @@ -128,7 +128,8 @@ try { label: 'Keira3 Repository', click: function () { shell.openExternal('https://github.com/AzerothCore/Keira3/') - } + }, + accelerator: process.platform === 'darwin' ? 'Cmd+F+1' : 'F1' }, { label: 'Report a Bug', @@ -155,6 +156,13 @@ try { }, ] }, + { + label: 'Wiki', + click: function () { + shell.openExternal('https://www.azerothcore.org/wiki/database-world') + }, + accelerator: 'CmdorCtrl+H' + }, { label: 'Join our Discord', click: function () { From 694d6adbe8bddfc99d61950bb807c0f6d830d41a Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 14 Jul 2020 14:36:59 +0200 Subject: [PATCH 6/6] codacy --- main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 2aedf095dff..47fb9f0af32 100644 --- a/main.ts +++ b/main.ts @@ -129,7 +129,7 @@ try { click: function () { shell.openExternal('https://github.com/AzerothCore/Keira3/') }, - accelerator: process.platform === 'darwin' ? 'Cmd+F+1' : 'F1' + accelerator: process.platform === 'darwin' ? 'Cmd+F+1' : 'F1', }, { label: 'Report a Bug', @@ -161,7 +161,7 @@ try { click: function () { shell.openExternal('https://www.azerothcore.org/wiki/database-world') }, - accelerator: 'CmdorCtrl+H' + accelerator: 'CmdorCtrl+H', }, { label: 'Join our Discord',