Make Tray available from renderers
This commit is contained in:
parent
3e5a71d236
commit
557a65ad97
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
18
main.js
18
main.js
|
@ -5,13 +5,14 @@ const {app, BrowserWindow, Tray} = require('electron')
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
|
let tray = null;
|
||||||
|
|
||||||
function initApp() {
|
function initApp() {
|
||||||
const tray = new Tray('./images/icon.png')
|
tray = new Tray('./images/icon.png')
|
||||||
tray.setToolTip('Chimeverse')
|
tray.setToolTip('Chimeverse')
|
||||||
createWindow()
|
createWindow();
|
||||||
|
|
||||||
tray.on('click', function() {
|
tray.on('click', function() {
|
||||||
|
hideEnvelope();
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,6 +41,7 @@ function createWindow () {
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
mainWindow.webContents.openDevTools();
|
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
|
// 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.
|
// 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;
|
Loading…
Reference in New Issue