mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
preparation for plugin menu update
This commit is contained in:
@ -1,11 +1,26 @@
|
||||
const {injectCSS} = require('../utils');
|
||||
const {Menu , app} = require('electron');
|
||||
const { existsSync } = require("fs");
|
||||
const path = require('path');
|
||||
const electronLocalshortcut = require("electron-localshortcut");
|
||||
const is = require('electron-is');
|
||||
const {getAllPlugins} = require('../../plugins/utils');
|
||||
const config = require('../../config');
|
||||
|
||||
const pluginEnabledMenu = (plugin, label = "") => ({
|
||||
label: label || plugin,
|
||||
type: "checkbox",
|
||||
checked: config.plugins.isEnabled(plugin),
|
||||
click: (item) => {
|
||||
if (item.checked) {
|
||||
config.plugins.enable(plugin);
|
||||
} else {
|
||||
config.plugins.disable(plugin);
|
||||
}
|
||||
checkCheckbox(item);
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = win => {
|
||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||
injectCSS(win.webContents, path.join(__dirname, 'style.css'));
|
||||
@ -42,21 +57,26 @@ const mainMenuTemplate = win => [
|
||||
label: 'Plugins',
|
||||
submenu: [
|
||||
...getAllPlugins().map(plugin => {
|
||||
return {
|
||||
label: plugin,
|
||||
type: 'checkbox',
|
||||
checked: config.plugins.isEnabled(plugin),
|
||||
click: item => {
|
||||
// CheckCheckbox(item);
|
||||
if (item.checked) {
|
||||
config.plugins.enable(plugin);
|
||||
} else {
|
||||
config.plugins.disable(plugin);
|
||||
}
|
||||
const pluginPath = path.join(__dirname, "plugins", plugin, "menu.js");
|
||||
|
||||
if (!config.plugins.isEnabled(plugin)) {
|
||||
return pluginEnabledMenu(plugin);
|
||||
}
|
||||
|
||||
checkCheckbox(item);
|
||||
}
|
||||
};
|
||||
if (existsSync(pluginPath)) {
|
||||
const getPluginMenu = require(pluginPath);
|
||||
return {
|
||||
label: plugin,
|
||||
submenu: [
|
||||
pluginEnabledMenu(plugin, "Enabled"),
|
||||
...getPluginMenu(win, config.plugins.getOptions(plugin), () =>
|
||||
module.exports.setApplicationMenu(win)
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return pluginEnabledMenu(plugin);
|
||||
}),
|
||||
{type: 'separator'},
|
||||
{
|
||||
@ -142,6 +162,50 @@ const mainMenuTemplate = win => [
|
||||
}
|
||||
] :
|
||||
[]),
|
||||
{
|
||||
label: 'Tray',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Disabled',
|
||||
type: 'radio',
|
||||
checked: !config.get('options.tray'),
|
||||
click: () => {
|
||||
config.set('options.tray', false);
|
||||
config.set('options.appVisible', true);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Enabled + app visible',
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && config.get('options.appVisible'),
|
||||
click: () => {
|
||||
config.set('options.tray', true);
|
||||
config.set('options.appVisible', true);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Enabled + app hidden',
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && !config.get('options.appVisible'),
|
||||
click: () => {
|
||||
config.set('options.tray', true);
|
||||
config.set('options.appVisible', false);
|
||||
}
|
||||
},
|
||||
{type: 'separator'},
|
||||
{
|
||||
label: 'Play/Pause on click',
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.trayClickPlayPause'),
|
||||
click: item => {
|
||||
config.set('options.trayClickPlayPause', item.checked);
|
||||
checkCheckbox(item);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{type: 'separator'},
|
||||
{
|
||||
@ -165,50 +229,6 @@ const mainMenuTemplate = win => [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Tray',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Disabled',
|
||||
type: 'radio',
|
||||
checked: !config.get('options.tray'),
|
||||
click: () => {
|
||||
config.set('options.tray', false);
|
||||
config.set('options.appVisible', true);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Enabled + app visible',
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && config.get('options.appVisible'),
|
||||
click: () => {
|
||||
config.set('options.tray', true);
|
||||
config.set('options.appVisible', true);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Enabled + app hidden',
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && !config.get('options.appVisible'),
|
||||
click: () => {
|
||||
config.set('options.tray', true);
|
||||
config.set('options.appVisible', false);
|
||||
}
|
||||
},
|
||||
{type: 'separator'},
|
||||
{
|
||||
label: 'Play/Pause on click',
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.trayClickPlayPause'),
|
||||
click: item => {
|
||||
config.set('options.trayClickPlayPause', item.checked);
|
||||
checkCheckbox(item);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/* allow submenu's to show correctly */
|
||||
.menubar-menu-container{
|
||||
overflow-y: visible !important;
|
||||
}
|
||||
/* remove window dragging for nav bar (conflict with titlebar drag) */
|
||||
ytmusic-nav-bar,
|
||||
.tab-titleiron-icon,
|
||||
|
||||
Reference in New Issue
Block a user