diff --git a/webapp/.yarnclean b/webapp/.yarnclean index d46a55524a..85d264e7d5 100644 --- a/webapp/.yarnclean +++ b/webapp/.yarnclean @@ -44,3 +44,5 @@ wercker.yml # misc *.md LICENSE +*.txt +!path.txt diff --git a/webapp/packages/main/public/icon.png b/webapp/packages/main/public/icon.png new file mode 100644 index 0000000000..1f8f6abf9e Binary files /dev/null and b/webapp/packages/main/public/icon.png differ diff --git a/webapp/packages/main/src/index.ts b/webapp/packages/main/src/index.ts index c4119febf0..c86c095791 100644 --- a/webapp/packages/main/src/index.ts +++ b/webapp/packages/main/src/index.ts @@ -1,4 +1,4 @@ -import {app, BrowserWindow, ipcMain, globalShortcut} from 'electron'; +import {app, Menu, Tray, BrowserWindow, ipcMain, globalShortcut} from 'electron'; import {URL} from 'url'; import {PyShell} from '/@/pyshell'; import {webuiArgs, webuiPath} from '/@/config'; @@ -69,7 +69,7 @@ const createWindow = async () => { mainWindow?.webContents.openDevTools(); } }); - + mainWindow.on('focus', function () { // Dev tools globalShortcut.register('Ctrl+Shift+I', function () { @@ -92,20 +92,50 @@ const createWindow = async () => { }); // Minimize, maximize, close window. + ipcMain.on('window-tray', function () { + mainWindow?.hide(); + }); ipcMain.on('window-min', function () { mainWindow?.minimize(); }); ipcMain.on('window-max', function () { - if (mainWindow?.isMaximized()) { - mainWindow?.restore(); - } else { - mainWindow?.maximize(); - } + mainWindow?.isMaximized() ? mainWindow?.restore() : mainWindow?.maximize(); }); ipcMain.on('window-close', function () { alas.kill(); setTimeout(() => mainWindow?.close(), 500); // Wait taskkill to finish }); + + // Tray + const tray = new Tray(path.join(__dirname, 'icon.png')); + const contextMenu = Menu.buildFromTemplate([ + { + label: 'Show', + click: function () { + mainWindow?.show(); + } + }, + { + label: 'Hide', + click: function () { + mainWindow?.hide(); + } + }, + { + label: 'Exit', + click: function () { + app.quit(); + } + } + ]); + tray.setToolTip('Alas'); + tray.setContextMenu(contextMenu); + tray.on('click', () => { + mainWindow?.isVisible() ? mainWindow?.hide() : mainWindow?.show() + }); + tray.on('right-click', () => { + tray.popUpContextMenu(contextMenu) + }); }; diff --git a/webapp/packages/renderer/assets/logo.svg b/webapp/packages/renderer/assets/logo.svg deleted file mode 100644 index 6471ae0723..0000000000 --- a/webapp/packages/renderer/assets/logo.svg +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/webapp/packages/renderer/src/components/AppHeader.vue b/webapp/packages/renderer/src/components/AppHeader.vue index 2cb9c0e029..e8aa004381 100644 --- a/webapp/packages/renderer/src/components/AppHeader.vue +++ b/webapp/packages/renderer/src/components/AppHeader.vue @@ -2,6 +2,7 @@