mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
remove redundant roles
This commit is contained in:
115
menu.js
115
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: [
|
||||||
@ -44,7 +44,7 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginEnabledMenu(win, plugin);
|
return pluginEnabledMenu(win, plugin);
|
||||||
}),
|
}),
|
||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
@ -101,28 +101,28 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
|||||||
},
|
},
|
||||||
...(is.windows() || is.linux()
|
...(is.windows() || is.linux()
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: "Hide menu",
|
label: "Hide menu",
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
checked: config.get("options.hideMenu"),
|
checked: config.get("options.hideMenu"),
|
||||||
click: (item) => {
|
click: (item) => {
|
||||||
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",
|
||||||
checked: config.get("options.startAtLogin"),
|
checked: config.get("options.startAtLogin"),
|
||||||
click: (item) => {
|
click: (item) => {
|
||||||
config.set("options.startAtLogin", item.checked);
|
config.set("options.startAtLogin", item.checked);
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
{
|
{
|
||||||
@ -192,52 +192,43 @@ const mainMenuTemplate = (win, withRoles = true) => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "View",
|
label: "View",
|
||||||
submenu: withRoles
|
submenu: [
|
||||||
? [
|
{
|
||||||
{ role: "reload" },
|
label: "Reload",
|
||||||
{ role: "forceReload" },
|
click: () => {
|
||||||
{ type: "separator" },
|
win.webContents.reload();
|
||||||
{ role: "zoomIn" },
|
},
|
||||||
{ role: "zoomOut" },
|
},
|
||||||
{ role: "resetZoom" },
|
{
|
||||||
]
|
label: "Force Reload",
|
||||||
: [
|
click: () => {
|
||||||
{
|
win.webContents.reloadIgnoringCache();
|
||||||
label: "Reload",
|
},
|
||||||
click: () => {
|
},
|
||||||
win.webContents.reload();
|
{ type: "separator" },
|
||||||
},
|
{
|
||||||
},
|
label: "Zoom In",
|
||||||
{
|
click: () => {
|
||||||
label: "Force Reload",
|
win.webContents.setZoomLevel(
|
||||||
click: () => {
|
win.webContents.getZoomLevel() + 1
|
||||||
win.webContents.reloadIgnoringCache();
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: "separator" },
|
{
|
||||||
{
|
label: "Zoom Out",
|
||||||
label: "Zoom In",
|
click: () => {
|
||||||
click: () => {
|
win.webContents.setZoomLevel(
|
||||||
win.webContents.setZoomLevel(
|
win.webContents.getZoomLevel() - 1
|
||||||
win.webContents.getZoomLevel() + 1
|
);
|
||||||
);
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
label: "Reset Zoom",
|
||||||
label: "Zoom Out",
|
click: () => {
|
||||||
click: () => {
|
win.webContents.setZoomLevel(0);
|
||||||
win.webContents.setZoomLevel(
|
},
|
||||||
win.webContents.getZoomLevel() - 1
|
},
|
||||||
);
|
],
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Reset Zoom",
|
|
||||||
click: () => {
|
|
||||||
win.webContents.setZoomLevel(0);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Navigation",
|
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
|
// 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