Meriadec Pillet
7 years ago
committed by
GitHub
8 changed files with 90 additions and 40 deletions
@ -1,30 +1,69 @@ |
|||
import { app, Menu } from 'electron' |
|||
import { BrowserWindow, app, Menu } from 'electron' |
|||
|
|||
const props = (predicate, values, defaultValue = {}) => (predicate ? values : defaultValue) |
|||
|
|||
const template = [ |
|||
...(process.platform === 'darwin' |
|||
? [ |
|||
{ |
|||
label: app.getName(), |
|||
submenu: [ |
|||
{ role: 'hide' }, |
|||
{ role: 'hideothers' }, |
|||
{ role: 'unhide' }, |
|||
...props( |
|||
process.platform === 'darwin', |
|||
[ |
|||
{ |
|||
label: app.getName(), |
|||
submenu: [ |
|||
{ role: 'hide' }, |
|||
{ role: 'hideothers' }, |
|||
{ role: 'unhide' }, |
|||
{ type: 'separator' }, |
|||
{ role: 'quit' }, |
|||
], |
|||
}, |
|||
], |
|||
[], |
|||
), |
|||
...props(process.platform === 'darwin' || __DEV__, [ |
|||
{ |
|||
role: 'window', |
|||
submenu: [ |
|||
...props( |
|||
__DEV__, |
|||
[ |
|||
{ |
|||
label: 'App Dev Tools', |
|||
click() { |
|||
const devWindow = BrowserWindow.getAllWindows().find(w => w.name === 'DevWindow') |
|||
if (devWindow) { |
|||
devWindow.show() |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: 'Main Window Dev Tools', |
|||
click() { |
|||
const mainWindow = BrowserWindow.getAllWindows().find(w => w.name === 'MainWindow') |
|||
if (mainWindow) { |
|||
mainWindow.openDevTools({ |
|||
mode: process.env.DEV_TOOLS_MODE, |
|||
}) |
|||
} |
|||
}, |
|||
}, |
|||
{ type: 'separator' }, |
|||
{ role: 'quit' }, |
|||
], |
|||
}, |
|||
{ |
|||
role: 'window', |
|||
submenu: [ |
|||
[], |
|||
), |
|||
...props( |
|||
process.platform === 'darwin', |
|||
[ |
|||
{ role: 'close' }, |
|||
{ role: 'minimize' }, |
|||
{ role: 'zoom' }, |
|||
{ type: 'separator' }, |
|||
{ role: 'front' }, |
|||
], |
|||
}, |
|||
] |
|||
: []), |
|||
[], |
|||
), |
|||
], |
|||
}, |
|||
]), |
|||
] |
|||
|
|||
export default Menu.buildFromTemplate(template) |
|||
|
@ -1,13 +1,13 @@ |
|||
require('dotenv').config() |
|||
const webpack = require('webpack') |
|||
const Dotenv = require('dotenv-webpack') |
|||
|
|||
require('../src/globals') |
|||
|
|||
module.exports = [ |
|||
new Dotenv(), |
|||
new webpack.DefinePlugin({ |
|||
__DEV__, |
|||
__PROD__, |
|||
__SENTRY_URL__: JSON.stringify(process.env.SENTRY_URL), |
|||
'process.env.NODE_ENV': JSON.stringify(__ENV__), |
|||
}), |
|||
] |
|||
|
Loading…
Reference in new issue