From 41738923958ff05cdd64e8964b3672a908219488 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 1 Jul 2020 20:28:57 -0400 Subject: [PATCH] added tray icon --- electron/src/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/electron/src/index.js b/electron/src/index.js index 7e9e8e6..5c8ff36 100644 --- a/electron/src/index.js +++ b/electron/src/index.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, autoUpdater, dialog} = require('electron'); +const { app, BrowserWindow, autoUpdater, dialog, Tray, Menu} = require('electron'); const path = require('path'); require('update-electron-app')({ repo:'jacobmichels/boosted', @@ -40,6 +40,19 @@ const createWindow = () => { resizable:false }); + mainWindow.on('minimize',event=>{ + event.preventDefault(); + mainWindow.hide(); + }); + + let appTray = new Tray(path.join(__dirname,'..\\resources\\icons\\lol-icon.png')); + let menu = Menu.buildFromTemplate([{label:'Show App',click:()=>{mainWindow.show();}},{label:'Quit',click:()=>{app.quit();}}]); + appTray.setContextMenu(menu); + appTray.on('double-click',()=>{ + mainWindow.show(); + }) + + mainWindow.on('ready-to-show',()=>{ mainWindow.show(); })