mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
preparation for plugin menu update
This commit is contained in:
@ -1,11 +1,26 @@
|
|||||||
const {injectCSS} = require('../utils');
|
const {injectCSS} = require('../utils');
|
||||||
const {Menu , app} = require('electron');
|
const {Menu , app} = require('electron');
|
||||||
|
const { existsSync } = require("fs");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const electronLocalshortcut = require("electron-localshortcut");
|
const electronLocalshortcut = require("electron-localshortcut");
|
||||||
const is = require('electron-is');
|
const is = require('electron-is');
|
||||||
const {getAllPlugins} = require('../../plugins/utils');
|
const {getAllPlugins} = require('../../plugins/utils');
|
||||||
const config = require('../../config');
|
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 => {
|
module.exports = win => {
|
||||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||||
injectCSS(win.webContents, path.join(__dirname, 'style.css'));
|
injectCSS(win.webContents, path.join(__dirname, 'style.css'));
|
||||||
@ -42,21 +57,26 @@ const mainMenuTemplate = win => [
|
|||||||
label: 'Plugins',
|
label: 'Plugins',
|
||||||
submenu: [
|
submenu: [
|
||||||
...getAllPlugins().map(plugin => {
|
...getAllPlugins().map(plugin => {
|
||||||
return {
|
const pluginPath = path.join(__dirname, "plugins", plugin, "menu.js");
|
||||||
label: plugin,
|
|
||||||
type: 'checkbox',
|
if (!config.plugins.isEnabled(plugin)) {
|
||||||
checked: config.plugins.isEnabled(plugin),
|
return pluginEnabledMenu(plugin);
|
||||||
click: item => {
|
}
|
||||||
// CheckCheckbox(item);
|
|
||||||
if (item.checked) {
|
|
||||||
config.plugins.enable(plugin);
|
|
||||||
} else {
|
|
||||||
config.plugins.disable(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'},
|
{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'},
|
{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',
|
label: 'View',
|
||||||
submenu: [
|
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) */
|
/* remove window dragging for nav bar (conflict with titlebar drag) */
|
||||||
ytmusic-nav-bar,
|
ytmusic-nav-bar,
|
||||||
.tab-titleiron-icon,
|
.tab-titleiron-icon,
|
||||||
|
|||||||
Reference in New Issue
Block a user