From 11f50478a7bc207ac3d9d021dbf05e9cb1597edb Mon Sep 17 00:00:00 2001 From: bubblepipe42 Date: Mon, 29 Sep 2025 13:25:22 +0800 Subject: [PATCH] tray --- electron/main.js | 86 +++++++++++++++--------------- electron/tray-iconTemplate.png | Bin 0 -> 459 bytes electron/tray-iconTemplate@2x.png | Bin 0 -> 754 bytes 3 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 electron/tray-iconTemplate.png create mode 100644 electron/tray-iconTemplate@2x.png 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 0000000000000000000000000000000000000000..187741e10d7ad49cae1e1624c3dfb5253355d15c GIT binary patch literal 459 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H3?x5i&EW)6jKx9jPK-BC>eK@{oCO|{#S9GG z!XV7ZFl&wkP_Qw;C&U#sR%fZ>$7zmYc*&kIant>eck|4iehX2gQcmEuz z{F=Cqqha|&@g1y&Q9jxs3q=B%)Lf^Ze_X8e;U;hDvn_g?JpUEm5dvyk4UX$+uyx4kfBSaIWU^~T@O3fm^-Kre+=ySF ztIN7`AEV68qdOf$gj<*MZ%*T%kkyu}&oDVnIL!Bma2BgTrd;A1okE#&RSFl@D1GU% z_B&L@y!aW1fUfGC726WB=3QBK{+fx4&*Zy3b6A)2uj2#x-P6_2Wt~$(69B(4fSCXQ literal 0 HcmV?d00001 diff --git a/electron/tray-iconTemplate@2x.png b/electron/tray-iconTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d5666a04e55b0233bb3c3981a361d1f61ea575e8 GIT binary patch literal 754 zcmeAS@N?(olHy`uVBq!ia0vp^Iv~u!3?wz9Rv7~+#^NA%C&rs6b?Si}&H|6fVg?3o zVGw3ym^DWND7Z1eC&U#<(-tr?Qf@vs7dImtJ1-9(0~3?yBj?9J6Rk^v{DK+&OR<)| z@c6UW_#^+~Ut2k5J`mR9I#O^({^GUsYC#Th;(3R59yh-|afM>FwWe=t+Uu`f%O0zo zbTf6`a%|?!3}7Hl_H=O!shIP2%JoTy40v4Ms`xd2VN?8a&-(Vi|A()MO1#-%ZT-7L z&gk0Jjf*_W7%Fbs&svwcU*)n&dHZdVBlh_#_`UekvNvo}p7QkU@->g6FIclOTv6Eg zc|qLSGC?(`GfXGWeA4cIDOd1kwf{89m3iFz%O1O3*>V5TQ~94gb*}vMbBs2Q zW&ExqberRQQt>Xci8r^XOuV)>`mf@0_o7!vlo`M4P1sWLY8%UQlLUj~CMP!^4xTL} z6I6R#ra6!68IPUarl{su-p>{?-C4R#e)sXjpv{>g0!qyLYYdkrJuWnmnWx9mvpiTJ zqWo&XncKG(#x>5^6>|8&i3gPhza1FLLb#Xa&G?}A^|$(auBkkNHAU=&arfnkhefSI<14qid^b4TcP^#>`ia1e z6$Z(U>06Q>$?eJ#yS#4&i#4MrQ|P8A+Y8g&B{r+`$G_{6+F|;c$MqZ68sisJ_p0yb t4fNr;^!CD8Vb}Vr(k55u*4>={R(g)PNNv{CrnR7Svd$@?2>^`i{gwa# literal 0 HcmV?d00001