mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
Add options to menu, export menu config
This commit is contained in:
86
menu.js
86
menu.js
@ -1,29 +1,75 @@
|
|||||||
const { app, Menu } = require("electron");
|
const { app, Menu } = require("electron");
|
||||||
|
|
||||||
const { isPluginEnabled, enablePlugin, disablePlugin } = require("./store");
|
|
||||||
const { getAllPlugins } = require("./plugins/utils");
|
const { getAllPlugins } = require("./plugins/utils");
|
||||||
|
const {
|
||||||
|
isPluginEnabled,
|
||||||
|
enablePlugin,
|
||||||
|
disablePlugin,
|
||||||
|
autoUpdate,
|
||||||
|
isAppVisible,
|
||||||
|
isTrayEnabled,
|
||||||
|
setOptions,
|
||||||
|
} = require("./store");
|
||||||
|
|
||||||
module.exports.setApplicationMenu = () => {
|
const mainMenuTemplate = [
|
||||||
const menuTemplate = [
|
{
|
||||||
{
|
label: "Plugins",
|
||||||
label : "Plugins",
|
submenu: getAllPlugins().map((plugin) => {
|
||||||
submenu: getAllPlugins().map(plugin => {
|
return {
|
||||||
return {
|
label: plugin,
|
||||||
label : plugin,
|
type: "checkbox",
|
||||||
type : "checkbox",
|
checked: isPluginEnabled(plugin),
|
||||||
checked: isPluginEnabled(plugin),
|
click: (item) => {
|
||||||
click : item => {
|
if (item.checked) {
|
||||||
if (item.checked) {
|
enablePlugin(plugin);
|
||||||
enablePlugin(plugin);
|
} else {
|
||||||
} else {
|
disablePlugin(plugin);
|
||||||
disablePlugin(plugin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
})
|
};
|
||||||
}
|
}),
|
||||||
];
|
},
|
||||||
|
{
|
||||||
|
label: "Options",
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Auto-update",
|
||||||
|
type: "checkbox",
|
||||||
|
checked: autoUpdate(),
|
||||||
|
click: (item) => {
|
||||||
|
setOptions({ autoUpdates: item.checked });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Tray",
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Disabled",
|
||||||
|
type: "radio",
|
||||||
|
checked: !isTrayEnabled(),
|
||||||
|
click: () => setOptions({ tray: false, appVisible: true }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Enabled + app visible",
|
||||||
|
type: "radio",
|
||||||
|
checked: isTrayEnabled() && isAppVisible(),
|
||||||
|
click: () => setOptions({ tray: true, appVisible: true }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Enabled + app hidden",
|
||||||
|
type: "radio",
|
||||||
|
checked: isTrayEnabled() && !isAppVisible(),
|
||||||
|
click: () => setOptions({ tray: true, appVisible: false }),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports.mainMenuTemplate = mainMenuTemplate;
|
||||||
|
module.exports.setApplicationMenu = () => {
|
||||||
|
const menuTemplate = [...mainMenuTemplate];
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
const name = app.getName();
|
const name = app.getName();
|
||||||
menuTemplate.unshift({
|
menuTemplate.unshift({
|
||||||
|
|||||||
Reference in New Issue
Block a user