Minimalize tray menu

-doesnt include main menu template anymore
This commit is contained in:
Araxeus
2021-04-03 15:47:32 +03:00
parent 216205200c
commit 2b3a20c5ff
2 changed files with 69 additions and 74 deletions

14
menu.js
View File

@ -23,18 +23,16 @@ const pluginEnabledMenu = (win, plugin, label = "", hasSubmenu = false) => ({
},
});
const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
const mainMenuTemplate = (win, withRoles = true) => [
{
label: "Plugins",
submenu: [
...getAllPlugins().map((plugin) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "menu.js");
const pluginPath = path.join(__dirname, "plugins", plugin, "menu.js")
if (existsSync(pluginPath)) {
if (!config.plugins.isEnabled(plugin)) {
return pluginEnabledMenu(win, plugin, "", true);
}
const getPluginMenu = require(pluginPath);
return {
label: plugin,
@ -192,8 +190,6 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
},
],
},
...(!isTray
? [
{
label: "View",
submenu: withRoles
@ -243,8 +239,6 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
},
],
},
]
: []),
{
label: "Navigation",
submenu: [
@ -271,16 +265,12 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
app.quit();
},
},
...(!isTray
? [
{
label: "Quit App",
click: () => {
app.quit();
},
},
]
: []),
],
},
];

View File

@ -3,7 +3,6 @@ const path = require("path");
const { Menu, nativeImage, Tray } = require("electron");
const config = require("./config");
const { mainMenuTemplate } = require("./menu");
const getSongControls = require("./providers/song-controls");
// Prevent tray being garbage collected
@ -57,7 +56,13 @@ module.exports.setUpTray = (app, win) => {
win.show();
},
},
...mainMenuTemplate(win, true, true),
{
label: "Restart App",
click: () => {
app.relaunch();
app.quit();
},
},
{
label: "Quit",
click: () => {