mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 19:33:59 +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');
|
const { autoUpdater } = require('electron-updater');
|
||||||
let win = null;
|
let win = null;
|
||||||
const instanceLock = app.requestSingleInstanceLock();
|
const instanceLock = app.requestSingleInstanceLock();
|
||||||
|
const isMacOS = process.platform === 'darwin';
|
||||||
|
|
||||||
if (require('electron-squirrel-startup')) app.quit();
|
if (require('electron-squirrel-startup')) app.quit();
|
||||||
|
|
||||||
const PORT = isDev ? '5173' : '51735';
|
const PORT = isDev ? '5173' : '51735';
|
||||||
|
const ICON = 'icon-rounded.png';
|
||||||
|
const ICON_TEMPLATE = 'iconTemplate.png';
|
||||||
|
|
||||||
function createWindow() {
|
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();
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
show: false,
|
show: false,
|
||||||
icon: iconPath,
|
icon: assetPath(ICON),
|
||||||
});
|
});
|
||||||
|
|
||||||
createTray(win);
|
createTray(win);
|
||||||
|
@ -41,12 +38,16 @@ function createWindow() {
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const assetPath = (asset) => {
|
||||||
|
return path.join(
|
||||||
|
__dirname,
|
||||||
|
isDev ? `../public/${asset}` : `../dist/${asset}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const createTray = (window) => {
|
const createTray = (window) => {
|
||||||
const tray = new Tray(
|
const tray = new Tray(
|
||||||
path.join(
|
assetPath(!isMacOS ? ICON : ICON_TEMPLATE)
|
||||||
__dirname,
|
|
||||||
isDev ? '../public/icon-rounded.png' : '../dist/icon-rounded.png'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
|
@ -76,7 +77,7 @@ const createTray = (window) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (!isMacOS) {
|
||||||
app.quit();
|
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