diff --git a/electron/main.js b/electron/main.js index 50307eac..bbe6e7cc 100644 --- a/electron/main.js +++ b/electron/main.js @@ -110,49 +110,6 @@ function waitForServer(resolve, reject, retries = 30) { req.end(); } -function createTray() { - tray = new Tray(path.join(__dirname, 'tray-icon.png')); - - const contextMenu = Menu.buildFromTemplate([ - { - label: 'Show New API', - click: () => { - if (mainWindow === null) { - createWindow(); - } else { - mainWindow.show(); - if (process.platform === 'darwin') { - app.dock.show(); - } - } - } - }, - { type: 'separator' }, - { - label: 'Quit', - click: () => { - app.isQuitting = true; - app.quit(); - } - } - ]); - - tray.setToolTip('New API'); - tray.setContextMenu(contextMenu); - - // On macOS, clicking the tray icon shows the menu - tray.on('click', () => { - if (mainWindow === null) { - createWindow(); - } else { - mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); - if (mainWindow.isVisible() && process.platform === 'darwin') { - app.dock.show(); - } - } - }); -} - function createWindow() { mainWindow = new BrowserWindow({ width: 1400, @@ -188,6 +145,49 @@ function createWindow() { }); } +function createTray() { + tray = new Tray(path.join(__dirname, 'tray-iconTemplate.png')); + + const contextMenu = Menu.buildFromTemplate([ + { + label: 'Show New API', + click: () => { + if (mainWindow === null) { + createWindow(); + } else { + mainWindow.show(); + if (process.platform === 'darwin') { + app.dock.show(); + } + } + } + }, + { type: 'separator' }, + { + label: 'Quit', + click: () => { + app.isQuitting = true; + app.quit(); + } + } + ]); + + tray.setToolTip('New API'); + tray.setContextMenu(contextMenu); + + // On macOS, clicking the tray icon shows the window + tray.on('click', () => { + if (mainWindow === null) { + createWindow(); + } else { + mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); + if (mainWindow.isVisible() && process.platform === 'darwin') { + app.dock.show(); + } + } + }); +} + app.whenReady().then(async () => { try { await startServer(); diff --git a/electron/tray-iconTemplate.png b/electron/tray-iconTemplate.png new file mode 100644 index 00000000..187741e1 Binary files /dev/null and b/electron/tray-iconTemplate.png differ diff --git a/electron/tray-iconTemplate@2x.png b/electron/tray-iconTemplate@2x.png new file mode 100644 index 00000000..d5666a04 Binary files /dev/null and b/electron/tray-iconTemplate@2x.png differ