mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
xo lint --fix
This commit is contained in:
@ -1,228 +1,226 @@
|
|||||||
const { injectCSS } = require("../utils");
|
const {injectCSS} = require('../utils');
|
||||||
const { Menu } = require("electron");
|
const {Menu} = require('electron');
|
||||||
const path = require("path");
|
const path = require('path');
|
||||||
|
|
||||||
const is = require("electron-is");
|
|
||||||
const { getAllPlugins } = require("../../plugins/utils");
|
|
||||||
const config = require("../../config");
|
|
||||||
|
|
||||||
|
|
||||||
|
const is = require('electron-is');
|
||||||
|
const {getAllPlugins} = require('../../plugins/utils');
|
||||||
|
const config = require('../../config');
|
||||||
|
|
||||||
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'));
|
||||||
win.on('ready-to-show', () => {
|
win.on('ready-to-show', () => {
|
||||||
const menu = Menu.buildFromTemplate(mainMenuTemplate(win));
|
const menu = Menu.buildFromTemplate(mainMenuTemplate(win));
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function checkCheckbox(item) {
|
function checkCheckbox(item) {
|
||||||
item.checked = !item.checked
|
item.checked = !item.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
//create new template because it works abit different (need to manually change checkbox + tray is out of submenu)
|
// Create new template because it works abit different (need to manually change checkbox + tray is out of submenu)
|
||||||
const mainMenuTemplate = (win) => [
|
const mainMenuTemplate = win => [
|
||||||
{
|
{
|
||||||
label: "Plugins",
|
label: 'Plugins',
|
||||||
submenu: [
|
submenu: [
|
||||||
...getAllPlugins().map((plugin) => {
|
...getAllPlugins().map(plugin => {
|
||||||
return {
|
return {
|
||||||
label: plugin,
|
label: plugin,
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.plugins.isEnabled(plugin),
|
checked: config.plugins.isEnabled(plugin),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
//checkCheckbox(item);
|
// CheckCheckbox(item);
|
||||||
if (item.checked) {
|
if (item.checked) {
|
||||||
config.plugins.enable(plugin);
|
config.plugins.enable(plugin);
|
||||||
} else {
|
} else {
|
||||||
config.plugins.disable(plugin);
|
config.plugins.disable(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
{ type: "separator" },
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
label: "Advanced options",
|
label: 'Advanced options',
|
||||||
click: () => {
|
click: () => {
|
||||||
config.edit();
|
config.edit();
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Options",
|
label: 'Options',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: "Auto-update",
|
label: 'Auto-update',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.autoUpdates"),
|
checked: config.get('options.autoUpdates'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.autoUpdates", item.checked);
|
config.set('options.autoUpdates', item.checked);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Disable hardware acceleration",
|
label: 'Disable hardware acceleration',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.disableHardwareAcceleration"),
|
checked: config.get('options.disableHardwareAcceleration'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.disableHardwareAcceleration", item.checked);
|
config.set('options.disableHardwareAcceleration', item.checked);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Restart on config changes",
|
label: 'Restart on config changes',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.restartOnConfigChanges"),
|
checked: config.get('options.restartOnConfigChanges'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.restartOnConfigChanges", item.checked);
|
config.set('options.restartOnConfigChanges', item.checked);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Reset App cache when app starts",
|
label: 'Reset App cache when app starts',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.autoResetAppCache"),
|
checked: config.get('options.autoResetAppCache'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.autoResetAppCache", item.checked);
|
config.set('options.autoResetAppCache', item.checked);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Resume last song when app starts",
|
label: 'Resume last song when app starts',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.resumeOnStart"),
|
checked: config.get('options.resumeOnStart'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.resumeOnStart", item.checked);
|
config.set('options.resumeOnStart', item.checked);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
...(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);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
] :
|
||||||
: []),
|
[]),
|
||||||
...(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);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
] :
|
||||||
: []),
|
[]),
|
||||||
|
|
||||||
{ type: "separator" },
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
label: "Toggle DevTools",
|
label: 'Toggle DevTools',
|
||||||
// Cannot use "toggleDevTools" role in MacOS
|
// Cannot use "toggleDevTools" role in MacOS
|
||||||
click: () => {
|
click: () => {
|
||||||
const { webContents } = win;
|
const {webContents} = win;
|
||||||
if (webContents.isDevToolsOpened()) {
|
if (webContents.isDevToolsOpened()) {
|
||||||
webContents.closeDevTools();
|
webContents.closeDevTools();
|
||||||
} else {
|
} else {
|
||||||
const devToolsOptions = {};
|
const devToolsOptions = {};
|
||||||
webContents.openDevTools(devToolsOptions);
|
webContents.openDevTools(devToolsOptions);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Advanced options",
|
label: 'Advanced options',
|
||||||
click: () => {
|
click: () => {
|
||||||
config.edit();
|
config.edit();
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tray",
|
label: 'Tray',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: "Disabled",
|
label: 'Disabled',
|
||||||
type: "radio",
|
type: 'radio',
|
||||||
checked: !config.get("options.tray"),
|
checked: !config.get('options.tray'),
|
||||||
click: () => {
|
click: () => {
|
||||||
config.set("options.tray", false);
|
config.set('options.tray', false);
|
||||||
config.set("options.appVisible", true);
|
config.set('options.appVisible', true);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Enabled + app visible",
|
label: 'Enabled + app visible',
|
||||||
type: "radio",
|
type: 'radio',
|
||||||
checked:
|
checked:
|
||||||
config.get("options.tray") && config.get("options.appVisible"),
|
config.get('options.tray') && config.get('options.appVisible'),
|
||||||
click: () => {
|
click: () => {
|
||||||
config.set("options.tray", true);
|
config.set('options.tray', true);
|
||||||
config.set("options.appVisible", true);
|
config.set('options.appVisible', true);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Enabled + app hidden",
|
label: 'Enabled + app hidden',
|
||||||
type: "radio",
|
type: 'radio',
|
||||||
checked:
|
checked:
|
||||||
config.get("options.tray") && !config.get("options.appVisible"),
|
config.get('options.tray') && !config.get('options.appVisible'),
|
||||||
click: () => {
|
click: () => {
|
||||||
config.set("options.tray", true);
|
config.set('options.tray', true);
|
||||||
config.set("options.appVisible", false);
|
config.set('options.appVisible', false);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{ type: "separator" },
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
label: "Play/Pause on click",
|
label: 'Play/Pause on click',
|
||||||
type: "checkbox",
|
type: 'checkbox',
|
||||||
checked: config.get("options.trayClickPlayPause"),
|
checked: config.get('options.trayClickPlayPause'),
|
||||||
click: (item) => {
|
click: item => {
|
||||||
config.set("options.trayClickPlayPause", item.checked);
|
config.set('options.trayClickPlayPause', item.checked);
|
||||||
checkCheckbox(item);
|
checkCheckbox(item);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "View",
|
label: 'View',
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: "reload" },
|
{role: 'reload'},
|
||||||
{ role: "forceReload" },
|
{role: 'forceReload'},
|
||||||
{ type: "separator" },
|
{type: 'separator'},
|
||||||
{ role: "zoomIn" },
|
{role: 'zoomIn'},
|
||||||
{ role: "zoomOut" },
|
{role: 'zoomOut'},
|
||||||
{ role: "resetZoom" },
|
{role: 'resetZoom'}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Navigation",
|
label: 'Navigation',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: "Go back",
|
label: 'Go back',
|
||||||
click: () => {
|
click: () => {
|
||||||
if (win.webContents.canGoBack()) {
|
if (win.webContents.canGoBack()) {
|
||||||
win.webContents.goBack();
|
win.webContents.goBack();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Go forward",
|
label: 'Go forward',
|
||||||
click: () => {
|
click: () => {
|
||||||
if (win.webContents.canGoForward()) {
|
if (win.webContents.canGoForward()) {
|
||||||
win.webContents.goForward();
|
win.webContents.goForward();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
const customTitlebar = require('custom-electron-titlebar');
|
const customTitlebar = require('custom-electron-titlebar');
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
const myBar = new customTitlebar.Titlebar({
|
const myBar = new customTitlebar.Titlebar({
|
||||||
backgroundColor: customTitlebar.Color.fromHex('#030303'),
|
backgroundColor: customTitlebar.Color.fromHex('#030303'),
|
||||||
itemBackgroundColor: customTitlebar.Color.fromHex('#121212'), //#020
|
itemBackgroundColor: customTitlebar.Color.fromHex('#121212') // #020
|
||||||
});
|
});
|
||||||
myBar.updateTitle(' ');
|
myBar.updateTitle(' ');
|
||||||
document.title = "Youtube Music";
|
document.title = 'Youtube Music';
|
||||||
}
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user