mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
remove redundant roles
This commit is contained in:
113
menu.js
113
menu.js
@ -23,7 +23,7 @@ const pluginEnabledMenu = (win, plugin, label = "", hasSubmenu = false) => ({
|
||||
},
|
||||
});
|
||||
|
||||
const mainMenuTemplate = (win, withRoles = true) => [
|
||||
const mainMenuTemplate = (win) => [
|
||||
{
|
||||
label: "Plugins",
|
||||
submenu: [
|
||||
@ -101,28 +101,28 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
||||
},
|
||||
...(is.windows() || is.linux()
|
||||
? [
|
||||
{
|
||||
label: "Hide menu",
|
||||
type: "checkbox",
|
||||
checked: config.get("options.hideMenu"),
|
||||
click: (item) => {
|
||||
config.set("options.hideMenu", item.checked);
|
||||
},
|
||||
{
|
||||
label: "Hide menu",
|
||||
type: "checkbox",
|
||||
checked: config.get("options.hideMenu"),
|
||||
click: (item) => {
|
||||
config.set("options.hideMenu", item.checked);
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(is.windows() || is.macOS()
|
||||
? // Only works on Win/Mac
|
||||
// https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
|
||||
[
|
||||
{
|
||||
label: "Start at login",
|
||||
type: "checkbox",
|
||||
checked: config.get("options.startAtLogin"),
|
||||
click: (item) => {
|
||||
config.set("options.startAtLogin", item.checked);
|
||||
},
|
||||
{
|
||||
label: "Start at login",
|
||||
type: "checkbox",
|
||||
checked: config.get("options.startAtLogin"),
|
||||
click: (item) => {
|
||||
config.set("options.startAtLogin", item.checked);
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
@ -192,52 +192,43 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
||||
},
|
||||
{
|
||||
label: "View",
|
||||
submenu: withRoles
|
||||
? [
|
||||
{ role: "reload" },
|
||||
{ role: "forceReload" },
|
||||
{ type: "separator" },
|
||||
{ role: "zoomIn" },
|
||||
{ role: "zoomOut" },
|
||||
{ role: "resetZoom" },
|
||||
]
|
||||
: [
|
||||
{
|
||||
label: "Reload",
|
||||
click: () => {
|
||||
win.webContents.reload();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Force Reload",
|
||||
click: () => {
|
||||
win.webContents.reloadIgnoringCache();
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Zoom In",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(
|
||||
win.webContents.getZoomLevel() + 1
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Zoom Out",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(
|
||||
win.webContents.getZoomLevel() - 1
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Reset Zoom",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(0);
|
||||
},
|
||||
},
|
||||
],
|
||||
submenu: [
|
||||
{
|
||||
label: "Reload",
|
||||
click: () => {
|
||||
win.webContents.reload();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Force Reload",
|
||||
click: () => {
|
||||
win.webContents.reloadIgnoringCache();
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Zoom In",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(
|
||||
win.webContents.getZoomLevel() + 1
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Zoom Out",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(
|
||||
win.webContents.getZoomLevel() - 1
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Reset Zoom",
|
||||
click: () => {
|
||||
win.webContents.setZoomLevel(0);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Navigation",
|
||||
|
||||
@ -16,7 +16,7 @@ const originalBuildMenu = Menu.buildFromTemplate;
|
||||
// This function natively gets called on all submenu so no more reason to use recursion
|
||||
Menu.buildFromTemplate = (template) => {
|
||||
// Fix checkboxes and radio buttons
|
||||
updateCheckboxesAndRadioButtons(win, template);
|
||||
updateCheckboxesAndRadioButtons(template);
|
||||
|
||||
// return as normal
|
||||
return originalBuildMenu(template);
|
||||
@ -39,21 +39,21 @@ module.exports = (winImport) => {
|
||||
|
||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||
if (config.get("options.hideMenu")) {
|
||||
switchMenuVisibility(win);
|
||||
switchMenuVisibility();
|
||||
electronLocalshortcut.register(win, "Esc", () => {
|
||||
switchMenuVisibility(win);
|
||||
switchMenuVisibility();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let visible = true;
|
||||
function switchMenuVisibility(win) {
|
||||
function switchMenuVisibility() {
|
||||
visible = !visible;
|
||||
win.webContents.send("updateMenu", visible);
|
||||
}
|
||||
|
||||
function checkCheckbox(win, item) {
|
||||
function checkCheckbox(item) {
|
||||
//check item
|
||||
item.checked = !item.checked;
|
||||
//update menu (closes it)
|
||||
@ -61,14 +61,14 @@ function checkCheckbox(win, item) {
|
||||
}
|
||||
|
||||
// Update checkboxes/radio buttons
|
||||
function updateCheckboxesAndRadioButtons(win, template) {
|
||||
function updateCheckboxesAndRadioButtons(template) {
|
||||
for (let item of template) {
|
||||
// Change onClick of checkbox+radio
|
||||
if ((item.type === "checkbox" || item.type === "radio") && !item.fixed) {
|
||||
let originalOnclick = item.click;
|
||||
item.click = (itemClicked) => {
|
||||
originalOnclick(itemClicked);
|
||||
checkCheckbox(win, itemClicked);
|
||||
checkCheckbox(itemClicked);
|
||||
};
|
||||
item.fixed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user