mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
Merge branch 'master' of github.com:th-ch/youtube-music into menu-options
# By Araxeus # Via GitHub (2) and Araxeus (1) * 'master' of github.com:th-ch/youtube-music: remove 'shortcuts'+'discord' from default plugins cleanup styled-bars code only refresh if plugin has a menu.js update styled-bars to support all changes permantly Refresh menu on plugin enable/disable
This commit is contained in:
17
menu.js
17
menu.js
@ -7,7 +7,7 @@ const is = require("electron-is");
|
||||
const { getAllPlugins } = require("./plugins/utils");
|
||||
const config = require("./config");
|
||||
|
||||
const pluginEnabledMenu = (plugin, label = "") => ({
|
||||
const pluginEnabledMenu = (win, plugin, label = "", hasSubmenu = false) => ({
|
||||
label: label || plugin,
|
||||
type: "checkbox",
|
||||
checked: config.plugins.isEnabled(plugin),
|
||||
@ -17,6 +17,9 @@ const pluginEnabledMenu = (plugin, label = "") => ({
|
||||
} else {
|
||||
config.plugins.disable(plugin);
|
||||
}
|
||||
if (hasSubmenu) {
|
||||
this.setApplicationMenu(win);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@ -27,16 +30,16 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
||||
...getAllPlugins().map((plugin) => {
|
||||
const pluginPath = path.join(__dirname, "plugins", plugin, "menu.js");
|
||||
|
||||
if (!config.plugins.isEnabled(plugin)) {
|
||||
return pluginEnabledMenu(plugin);
|
||||
}
|
||||
|
||||
if (existsSync(pluginPath)) {
|
||||
if (!config.plugins.isEnabled(plugin)) {
|
||||
return pluginEnabledMenu(win, plugin, "", true);
|
||||
}
|
||||
|
||||
const getPluginMenu = require(pluginPath);
|
||||
return {
|
||||
label: plugin,
|
||||
submenu: [
|
||||
pluginEnabledMenu(plugin, "Enabled"),
|
||||
pluginEnabledMenu(win, plugin, "Enabled", true),
|
||||
...getPluginMenu(win, config.plugins.getOptions(plugin), () =>
|
||||
module.exports.setApplicationMenu(win)
|
||||
),
|
||||
@ -44,7 +47,7 @@ const mainMenuTemplate = (win, withRoles = true, isTray = false) => [
|
||||
};
|
||||
}
|
||||
|
||||
return pluginEnabledMenu(plugin);
|
||||
return pluginEnabledMenu(win, plugin);
|
||||
}),
|
||||
{ type: "separator" },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user