Clean logs on start - and eslint/mocha with code coverage (#1945)
* Clean logs on startup; install server-side testing/linting * Add eslint config, make all of app/ conform to its demands * Add Node.js testing and linting to CI * Lock project to Node.js 7.9.0, used by Electron 1.7.10 * New eslint error: trailing commas in function argumensts Node 7.9.0 doesn't like trailing commas, but Electron does * Move electron to devDependency, tell eslint it's built-in
This commit is contained in:
parent
6464d0a5fa
commit
64fe9dbfb2
21 changed files with 1782 additions and 316 deletions
|
@ -1,23 +1,24 @@
|
|||
const electron = require('electron')
|
||||
const path = require('path');
|
||||
|
||||
const app = electron.app;
|
||||
const Menu = electron.Menu;
|
||||
const Tray = electron.Tray;
|
||||
const {
|
||||
app,
|
||||
Menu,
|
||||
Tray,
|
||||
} = require('electron');
|
||||
|
||||
let trayContextMenu = null;
|
||||
let tray = null;
|
||||
|
||||
function createTrayIcon(getMainWindow, messages) {
|
||||
|
||||
// A smaller icon is needed on macOS
|
||||
tray = new Tray(
|
||||
process.platform == "darwin" ?
|
||||
path.join(__dirname, '..', 'images', 'icon_16.png') :
|
||||
path.join(__dirname, '..', 'images', 'icon_256.png'));
|
||||
process.platform === 'darwin' ?
|
||||
path.join(__dirname, '..', 'images', 'icon_16.png') :
|
||||
path.join(__dirname, '..', 'images', 'icon_256.png')
|
||||
);
|
||||
|
||||
tray.toggleWindowVisibility = function () {
|
||||
var mainWindow = getMainWindow();
|
||||
tray.toggleWindowVisibility = () => {
|
||||
const mainWindow = getMainWindow();
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
|
@ -33,31 +34,28 @@ function createTrayIcon(getMainWindow, messages) {
|
|||
}
|
||||
}
|
||||
tray.updateContextMenu();
|
||||
}
|
||||
};
|
||||
|
||||
tray.updateContextMenu = function () {
|
||||
|
||||
var mainWindow = getMainWindow();
|
||||
tray.updateContextMenu = () => {
|
||||
const mainWindow = getMainWindow();
|
||||
|
||||
// NOTE: we want to have the show/hide entry available in the tray icon
|
||||
// context menu, since the 'click' event may not work on all platforms.
|
||||
// For details please refer to:
|
||||
// https://github.com/electron/electron/blob/master/docs/api/tray.md.
|
||||
trayContextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
id: 'toggleWindowVisibility',
|
||||
label: messages[mainWindow.isVisible() ? 'hide' : 'show'].message,
|
||||
click: tray.toggleWindowVisibility
|
||||
},
|
||||
{
|
||||
id: 'quit',
|
||||
label: messages.quit.message,
|
||||
click: app.quit.bind(app)
|
||||
}
|
||||
]);
|
||||
trayContextMenu = Menu.buildFromTemplate([{
|
||||
id: 'toggleWindowVisibility',
|
||||
label: messages[mainWindow.isVisible() ? 'hide' : 'show'].message,
|
||||
click: tray.toggleWindowVisibility,
|
||||
},
|
||||
{
|
||||
id: 'quit',
|
||||
label: messages.quit.message,
|
||||
click: app.quit.bind(app),
|
||||
}]);
|
||||
|
||||
tray.setContextMenu(trayContextMenu);
|
||||
}
|
||||
};
|
||||
|
||||
tray.on('click', tray.toggleWindowVisibility);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue