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 0000000..ef6d47d Binary files /dev/null and b/public/iconTemplate.png differ diff --git a/public/iconTemplate@2x.png b/public/iconTemplate@2x.png new file mode 100644 index 0000000..c41c4f8 Binary files /dev/null and b/public/iconTemplate@2x.png differ diff --git a/public/iconTemplate@3x.png b/public/iconTemplate@3x.png new file mode 100644 index 0000000..0ad77d4 Binary files /dev/null and b/public/iconTemplate@3x.png differ