Merge branch 'menu-patch'
This commit is contained in:
commit
2fa5cdcfbb
2 changed files with 62 additions and 40 deletions
|
@ -1,6 +1,7 @@
|
|||
const {app, BrowserWindow, ipcMain} = require('electron');
|
||||
const url = require('url');
|
||||
const isDebug = process.env.NODE_ENV === 'development'
|
||||
const isDebug = process.env.NODE_ENV === 'development';
|
||||
const setMenu = require('./menu/main-menu.js');
|
||||
|
||||
if (isDebug) {
|
||||
try
|
||||
|
@ -169,6 +170,12 @@ function createWindow () {
|
|||
win.on('closed', () => {
|
||||
win = null
|
||||
})
|
||||
|
||||
// Menu bar
|
||||
win.setAutoHideMenuBar(true);
|
||||
win.setMenuBarVisibility(isDebug);
|
||||
setMenu();
|
||||
|
||||
};
|
||||
|
||||
function handleOpenUriRequested(uri) {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
const {Menu} = require('electron');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const { app, shell, Menu } = require('electron');
|
||||
|
||||
const baseTemplate = [
|
||||
{
|
||||
|
@ -30,16 +28,65 @@ const baseTemplate = [
|
|||
]
|
||||
},
|
||||
{
|
||||
label: 'Help',
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Help',
|
||||
role: 'reload'
|
||||
},
|
||||
{
|
||||
label: 'Developer',
|
||||
submenu: [
|
||||
{
|
||||
role: 'forcereload'
|
||||
},
|
||||
{
|
||||
role: 'toggledevtools'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'togglefullscreen'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click(item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.webContents.send('open-menu', '/help');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Frequently Asked Questions',
|
||||
click(item, focusedWindow){
|
||||
shell.openExternal('https://lbry.io/faq')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Report Issue',
|
||||
click(item, focusedWindow){
|
||||
shell.openExternal('https://lbry.io/faq/contributing#report-a-bug');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Developer API Guide',
|
||||
click(item, focusedWindow){
|
||||
shell.openExternal('https://lbry.io/quickstart')
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
@ -71,40 +118,8 @@ const macOSAppMenuTemplate = {
|
|||
]
|
||||
};
|
||||
|
||||
const developerMenuTemplate = {
|
||||
label: 'Developer',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click(item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: process.platform == 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||
click(item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
showMenubar(showDeveloperMenu) {
|
||||
module.exports = () => {
|
||||
let template = baseTemplate.slice();
|
||||
if (process.platform === 'darwin') {
|
||||
template.unshift(macOSAppMenuTemplate);
|
||||
}
|
||||
if (showDeveloperMenu) {
|
||||
template.push(developerMenuTemplate);
|
||||
}
|
||||
|
||||
(process.platform === 'darwin') && template.unshift(macOSAppMenuTemplate);
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue