From c7a355b407899e2a6bfb74f20666a31273c8cd87 Mon Sep 17 00:00:00 2001 From: Mario Dian Date: Tue, 20 Jun 2023 14:23:24 +0800 Subject: [PATCH] fix menubar icon size in macOS (#360) add support for MacOS theme (light/dark) --- electron/index.cjs | 25 +++++++++++++------------ public/iconTemplate.png | Bin 0 -> 1647 bytes public/iconTemplate@2x.png | Bin 0 -> 2949 bytes public/iconTemplate@3x.png | Bin 0 -> 4894 bytes 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 public/iconTemplate.png create mode 100644 public/iconTemplate@2x.png create mode 100644 public/iconTemplate@3x.png diff --git a/electron/index.cjs b/electron/index.cjs index c1e6949..db0121c 100644 --- a/electron/index.cjs +++ b/electron/index.cjs @@ -5,24 +5,21 @@ const isDev = require('electron-is-dev'); const { autoUpdater } = require('electron-updater'); let win = null; const instanceLock = app.requestSingleInstanceLock(); +const isMacOS = process.platform === 'darwin'; if (require('electron-squirrel-startup')) app.quit(); const PORT = isDev ? '5173' : '51735'; +const ICON = 'icon-rounded.png'; +const ICON_TEMPLATE = 'iconTemplate.png'; function createWindow() { - let iconPath = ''; - if (isDev) { - iconPath = path.join(__dirname, '../public/icon-rounded.png'); - } else { - iconPath = path.join(__dirname, '../dist/icon-rounded.png'); - } autoUpdater.checkForUpdatesAndNotify(); win = new BrowserWindow({ autoHideMenuBar: true, show: false, - icon: iconPath, + icon: assetPath(ICON), }); createTray(win); @@ -41,12 +38,16 @@ function createWindow() { return win; } +const assetPath = (asset) => { + return path.join( + __dirname, + isDev ? `../public/${asset}` : `../dist/${asset}` + ) +} + const createTray = (window) => { const tray = new Tray( - path.join( - __dirname, - isDev ? '../public/icon-rounded.png' : '../dist/icon-rounded.png' - ) + assetPath(!isMacOS ? ICON : ICON_TEMPLATE) ); const contextMenu = Menu.buildFromTemplate([ { @@ -76,7 +77,7 @@ const createTray = (window) => { }; app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { + if (!isMacOS) { app.quit(); } }); diff --git a/public/iconTemplate.png b/public/iconTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..ef6d47d5d0ac1e8efeae8b4e8b640642452def2a GIT binary patch literal 1647 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vr;2G(|mmyw18|51~x_^24*0O z5eOL=r5ISjYzBrfMrk-Zj!^@uh6$*~kO4?Chyrn1dnN-5RDBJQ1_2Ks2ATw+12QX8 zb8-_)@{1G#it-hV^^En*fO1R=nBe*Z7BC~&Ksg3YP775a#aZAHS&Eh9J^LA43{lD?(>zUS^4%5mXDBFuJZt zggiD2k)_eK`WI!U0uv+Ht%gwBkj0?tZS+Cu5h;B_5E87yEojEhp zIBDwE?c3jTD)KPgbx7wr&vg0T?~hqqf2}l)-x;ho{rc6ct$`0}vTLSF8q7?+nXoh{ zGK*=+qv;10PLWWtWwB%aefG@>tpzi6PWOdrO;zPjNHcHTx2JpNT!vc>dY&ZR&d%o{IApRh3VSs?abOx(f?#;*N6hA)jkmUno z#KbEdhH@-sUb8qA=P<`TaqYXW#CSu>DWcPG9-G;53Hj>xyU)DInx*A!^)d{Z{Y4L^bRE7V0xE1hUHx3vIVCg!0IYZ%5C8xG literal 0 HcmV?d00001 diff --git a/public/iconTemplate@2x.png b/public/iconTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c41c4f8909ed8360f8056764e9cf5459dde226ab GIT binary patch literal 2949 zcmZ`*4?NTP8~=`&bp9OI`PVT_6#Hjd48wBeyC^4RbO|#Vo3YLLe@!=aU8I}Jg{a@A zPI85_P8sWR`rV=WjTj5NTuD)W{tTy|e&5lR>+YVtKA+FC=Xu`Gzt8j8Ye$23Y%|ce z)CT~-01WUCflh>G>FGi{H#2h@I!fqNFfJ$v*a-1@fG*4g(1th|^Z{U&fX)&R0DE9o zZ}>=<(`y?o$OZ>MJFpg7aYq=ys@L|}(5aySXhEKq&tOJ6oym&ku{nrf4jX|-^R|oU@sf!cOj=qRIt`Cza}Ho|9v&VTtSiRV6$M$KxE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