mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-27 07:45:08 +02:00
mac menubar icon (wip)
This commit is contained in:
parent
e477a6a3e6
commit
0e148594fb
|
@ -88,10 +88,17 @@ app.openWindow = function (opts) {
|
||||||
return new electron.BrowserWindow(opts);
|
return new electron.BrowserWindow(opts);
|
||||||
};
|
};
|
||||||
app.minimizeApp = function () {
|
app.minimizeApp = function () {
|
||||||
if (process.platform !== 'darwin') {
|
let imagePath;
|
||||||
mainWindow.minimize();
|
if (process.platform === 'darwin') {
|
||||||
|
mainWindow.hide();
|
||||||
|
app.dock.hide();
|
||||||
|
imagePath = 'mac-menubar-icon.png';
|
||||||
|
} else {
|
||||||
|
imagePath = 'icon.png';
|
||||||
|
}
|
||||||
mainWindow.setSkipTaskbar(true);
|
mainWindow.setSkipTaskbar(true);
|
||||||
appIcon = new electron.Tray(path.join(__dirname, 'icon.png'));
|
const image = electron.nativeImage.createFromPath(path.join(__dirname, imagePath));
|
||||||
|
appIcon = new electron.Tray(image);
|
||||||
appIcon.on('click', restoreMainWindow);
|
appIcon.on('click', restoreMainWindow);
|
||||||
const contextMenu = electron.Menu.buildFromTemplate([
|
const contextMenu = electron.Menu.buildFromTemplate([
|
||||||
{label: 'Open KeeWeb', click: restoreMainWindow},
|
{label: 'Open KeeWeb', click: restoreMainWindow},
|
||||||
|
@ -99,7 +106,6 @@ app.minimizeApp = function () {
|
||||||
]);
|
]);
|
||||||
appIcon.setContextMenu(contextMenu);
|
appIcon.setContextMenu(contextMenu);
|
||||||
appIcon.setToolTip('KeeWeb');
|
appIcon.setToolTip('KeeWeb');
|
||||||
}
|
|
||||||
};
|
};
|
||||||
app.getMainWindow = function () {
|
app.getMainWindow = function () {
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
|
@ -176,6 +182,10 @@ function createMainWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreMainWindow() {
|
function restoreMainWindow() {
|
||||||
|
// if (process.platform === 'darwin') {
|
||||||
|
// app.dock.show();
|
||||||
|
// mainWindow.show();
|
||||||
|
// }
|
||||||
if (mainWindow.isMinimized()) {
|
if (mainWindow.isMinimized()) {
|
||||||
mainWindow.restore();
|
mainWindow.restore();
|
||||||
}
|
}
|
||||||
|
|
BIN
desktop/mac-menubar-icon@2x.png
Normal file
BIN
desktop/mac-menubar-icon@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue
Block a user