mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 17:24:00 +01:00
fix menubar icon size in macOS (#360)
add support for MacOS theme (light/dark)
This commit is contained in:
parent
6db0decdb9
commit
c7a355b407
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
BIN
public/iconTemplate.png
Normal file
BIN
public/iconTemplate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
public/iconTemplate@2x.png
Normal file
BIN
public/iconTemplate@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
public/iconTemplate@3x.png
Normal file
BIN
public/iconTemplate@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
Loading…
Reference in a new issue