mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 12:21:47 +00:00
Minimalize tray menu
-doesnt include main menu template anymore
This commit is contained in:
132
menu.js
132
menu.js
@ -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",
|
label: "Plugins",
|
||||||
submenu: [
|
submenu: [
|
||||||
...getAllPlugins().map((plugin) => {
|
...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 (existsSync(pluginPath)) {
|
||||||
if (!config.plugins.isEnabled(plugin)) {
|
if (!config.plugins.isEnabled(plugin)) {
|
||||||
return pluginEnabledMenu(win, plugin, "", true);
|
return pluginEnabledMenu(win, plugin, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPluginMenu = require(pluginPath);
|
const getPluginMenu = require(pluginPath);
|
||||||
return {
|
return {
|
||||||
label: plugin,
|
label: plugin,
|
||||||
@ -111,12 +109,12 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
|||||||
config.set("options.hideMenu", item.checked);
|
config.set("options.hideMenu", item.checked);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(is.windows() || is.macOS()
|
...(is.windows() || is.macOS()
|
||||||
? // Only works on Win/Mac
|
? // Only works on Win/Mac
|
||||||
// https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
|
// https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: "Start at login",
|
label: "Start at login",
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
@ -125,7 +123,7 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
|||||||
config.set("options.startAtLogin", item.checked);
|
config.set("options.startAtLogin", item.checked);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
{
|
{
|
||||||
label: "Tray",
|
label: "Tray",
|
||||||
@ -192,59 +190,55 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
...(!isTray
|
{
|
||||||
? [
|
label: "View",
|
||||||
{
|
submenu: withRoles
|
||||||
label: "View",
|
? [
|
||||||
submenu: withRoles
|
{ role: "reload" },
|
||||||
? [
|
{ role: "forceReload" },
|
||||||
{ role: "reload" },
|
{ type: "separator" },
|
||||||
{ role: "forceReload" },
|
{ role: "zoomIn" },
|
||||||
{ type: "separator" },
|
{ role: "zoomOut" },
|
||||||
{ role: "zoomIn" },
|
{ role: "resetZoom" },
|
||||||
{ role: "zoomOut" },
|
]
|
||||||
{ role: "resetZoom" },
|
: [
|
||||||
]
|
{
|
||||||
: [
|
label: "Reload",
|
||||||
{
|
click: () => {
|
||||||
label: "Reload",
|
win.webContents.reload();
|
||||||
click: () => {
|
},
|
||||||
win.webContents.reload();
|
},
|
||||||
},
|
{
|
||||||
},
|
label: "Force Reload",
|
||||||
{
|
click: () => {
|
||||||
label: "Force Reload",
|
win.webContents.reloadIgnoringCache();
|
||||||
click: () => {
|
},
|
||||||
win.webContents.reloadIgnoringCache();
|
},
|
||||||
},
|
{ type: "separator" },
|
||||||
},
|
{
|
||||||
{ type: "separator" },
|
label: "Zoom In",
|
||||||
{
|
click: () => {
|
||||||
label: "Zoom In",
|
win.webContents.setZoomLevel(
|
||||||
click: () => {
|
win.webContents.getZoomLevel() + 1
|
||||||
win.webContents.setZoomLevel(
|
);
|
||||||
win.webContents.getZoomLevel() + 1
|
},
|
||||||
);
|
},
|
||||||
},
|
{
|
||||||
},
|
label: "Zoom Out",
|
||||||
{
|
click: () => {
|
||||||
label: "Zoom Out",
|
win.webContents.setZoomLevel(
|
||||||
click: () => {
|
win.webContents.getZoomLevel() - 1
|
||||||
win.webContents.setZoomLevel(
|
);
|
||||||
win.webContents.getZoomLevel() - 1
|
},
|
||||||
);
|
},
|
||||||
},
|
{
|
||||||
},
|
label: "Reset Zoom",
|
||||||
{
|
click: () => {
|
||||||
label: "Reset Zoom",
|
win.webContents.setZoomLevel(0);
|
||||||
click: () => {
|
},
|
||||||
win.webContents.setZoomLevel(0);
|
},
|
||||||
},
|
],
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
{
|
||||||
label: "Navigation",
|
label: "Navigation",
|
||||||
submenu: [
|
submenu: [
|
||||||
@ -271,16 +265,12 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
|||||||
app.quit();
|
app.quit();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...(!isTray
|
{
|
||||||
? [
|
label: "Quit App",
|
||||||
{
|
click: () => {
|
||||||
label: "Quit App",
|
app.quit();
|
||||||
click: () => {
|
},
|
||||||
app.quit();
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
9
tray.js
9
tray.js
@ -3,7 +3,6 @@ const path = require("path");
|
|||||||
const { Menu, nativeImage, Tray } = require("electron");
|
const { Menu, nativeImage, Tray } = require("electron");
|
||||||
|
|
||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
const { mainMenuTemplate } = require("./menu");
|
|
||||||
const getSongControls = require("./providers/song-controls");
|
const getSongControls = require("./providers/song-controls");
|
||||||
|
|
||||||
// Prevent tray being garbage collected
|
// Prevent tray being garbage collected
|
||||||
@ -57,7 +56,13 @@ module.exports.setUpTray = (app, win) => {
|
|||||||
win.show();
|
win.show();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...mainMenuTemplate(win, true, true),
|
{
|
||||||
|
label: "Restart App",
|
||||||
|
click: () => {
|
||||||
|
app.relaunch();
|
||||||
|
app.quit();
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Quit",
|
label: "Quit",
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user