Make Tray available from renderers

This commit is contained in:
Nick Denry 2019-04-25 17:19:18 +03:00
parent 3e5a71d236
commit 557a65ad97
2 changed files with 15 additions and 3 deletions

BIN
images/envelope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

18
main.js
View File

@ -5,13 +5,14 @@ const {app, BrowserWindow, Tray} = require('electron')
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
let tray = null;
function initApp() {
const tray = new Tray('./images/icon.png')
tray = new Tray('./images/icon.png')
tray.setToolTip('Chimeverse')
createWindow()
createWindow();
tray.on('click', function() {
hideEnvelope();
mainWindow.show();
});
}
@ -40,6 +41,7 @@ function createWindow () {
mainWindow = null
})
mainWindow.webContents.openDevTools();
}
@ -63,3 +65,13 @@ app.on('activate', function () {
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
function showEnvelope() {
tray.setImage('./images/envelope.png')
}
function hideEnvelope() {
tray.setImage('./images/icon.png')
}
exports.showEnvelope = showEnvelope;