mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
remove redundant roles
This commit is contained in:
13
menu.js
13
menu.js
@ -23,7 +23,7 @@ const pluginEnabledMenu = (win, plugin, label = "", hasSubmenu = false) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const mainMenuTemplate = (win, withRoles = true) => [
|
const mainMenuTemplate = (win) => [
|
||||||
{
|
{
|
||||||
label: "Plugins",
|
label: "Plugins",
|
||||||
submenu: [
|
submenu: [
|
||||||
@ -192,16 +192,7 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "View",
|
label: "View",
|
||||||
submenu: withRoles
|
submenu: [
|
||||||
? [
|
|
||||||
{ role: "reload" },
|
|
||||||
{ role: "forceReload" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "zoomIn" },
|
|
||||||
{ role: "zoomOut" },
|
|
||||||
{ role: "resetZoom" },
|
|
||||||
]
|
|
||||||
: [
|
|
||||||
{
|
{
|
||||||
label: "Reload",
|
label: "Reload",
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const originalBuildMenu = Menu.buildFromTemplate;
|
|||||||
// This function natively gets called on all submenu so no more reason to use recursion
|
// This function natively gets called on all submenu so no more reason to use recursion
|
||||||
Menu.buildFromTemplate = (template) => {
|
Menu.buildFromTemplate = (template) => {
|
||||||
// Fix checkboxes and radio buttons
|
// Fix checkboxes and radio buttons
|
||||||
updateCheckboxesAndRadioButtons(win, template);
|
updateCheckboxesAndRadioButtons(template);
|
||||||
|
|
||||||
// return as normal
|
// return as normal
|
||||||
return originalBuildMenu(template);
|
return originalBuildMenu(template);
|
||||||
@ -39,21 +39,21 @@ module.exports = (winImport) => {
|
|||||||
|
|
||||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||||
if (config.get("options.hideMenu")) {
|
if (config.get("options.hideMenu")) {
|
||||||
switchMenuVisibility(win);
|
switchMenuVisibility();
|
||||||
electronLocalshortcut.register(win, "Esc", () => {
|
electronLocalshortcut.register(win, "Esc", () => {
|
||||||
switchMenuVisibility(win);
|
switchMenuVisibility();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let visible = true;
|
let visible = true;
|
||||||
function switchMenuVisibility(win) {
|
function switchMenuVisibility() {
|
||||||
visible = !visible;
|
visible = !visible;
|
||||||
win.webContents.send("updateMenu", visible);
|
win.webContents.send("updateMenu", visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCheckbox(win, item) {
|
function checkCheckbox(item) {
|
||||||
//check item
|
//check item
|
||||||
item.checked = !item.checked;
|
item.checked = !item.checked;
|
||||||
//update menu (closes it)
|
//update menu (closes it)
|
||||||
@ -61,14 +61,14 @@ function checkCheckbox(win, item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update checkboxes/radio buttons
|
// Update checkboxes/radio buttons
|
||||||
function updateCheckboxesAndRadioButtons(win, template) {
|
function updateCheckboxesAndRadioButtons(template) {
|
||||||
for (let item of template) {
|
for (let item of template) {
|
||||||
// Change onClick of checkbox+radio
|
// Change onClick of checkbox+radio
|
||||||
if ((item.type === "checkbox" || item.type === "radio") && !item.fixed) {
|
if ((item.type === "checkbox" || item.type === "radio") && !item.fixed) {
|
||||||
let originalOnclick = item.click;
|
let originalOnclick = item.click;
|
||||||
item.click = (itemClicked) => {
|
item.click = (itemClicked) => {
|
||||||
originalOnclick(itemClicked);
|
originalOnclick(itemClicked);
|
||||||
checkCheckbox(win, itemClicked);
|
checkCheckbox(itemClicked);
|
||||||
};
|
};
|
||||||
item.fixed = true;
|
item.fixed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user