mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
update styled-bars to support
all changes permantly
This commit is contained in:
@ -5,16 +5,16 @@ const electronLocalshortcut = require("electron-localshortcut");
|
|||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
var { mainMenuTemplate } = require("../../menu");
|
var { mainMenuTemplate } = require("../../menu");
|
||||||
|
|
||||||
//override menu template for custom menu
|
//override Menu.buildFromTemplate to also fix menu
|
||||||
const originTemplate = mainMenuTemplate;
|
const originBuildMenu = Menu.buildFromTemplate;
|
||||||
mainMenuTemplate = function (winHook) {
|
//this function natively gets called on all submenu so no more reason to use recursion
|
||||||
//get template
|
Menu.buildFromTemplate = function (template) {
|
||||||
let template = originTemplate(winHook);
|
|
||||||
//fix checkbox and roles
|
//fix checkbox and roles
|
||||||
fixMenu(template);
|
fixMenu(template);
|
||||||
//return as normal
|
//return as normal
|
||||||
return template;
|
return originBuildMenu(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
//win hook for fixing menu
|
//win hook for fixing menu
|
||||||
let win;
|
let win;
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ let win;
|
|||||||
let done = false;
|
let done = false;
|
||||||
|
|
||||||
module.exports = winImport => {
|
module.exports = winImport => {
|
||||||
|
//override menu template for custom menu
|
||||||
win = winImport;
|
win = winImport;
|
||||||
// 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'));
|
||||||
@ -55,12 +56,9 @@ function switchMenuVisibility() {
|
|||||||
function fixMenu(template) {
|
function fixMenu(template) {
|
||||||
for (let index in template) {
|
for (let index in template) {
|
||||||
let item = template[index];
|
let item = template[index];
|
||||||
//apply function on submenu
|
//change onClick of checkbox+radio if not fixed
|
||||||
if (item.submenu != null) {
|
if ((item.type === 'checkbox' || item.type === 'radio') && !item.fixed) {
|
||||||
fixMenu(item.submenu);
|
item.fixed = true;
|
||||||
}
|
|
||||||
//change onClick of checkbox+radio
|
|
||||||
else if (item.type === 'checkbox' || item.type === 'radio') {
|
|
||||||
let ogOnclick = item.click;
|
let ogOnclick = item.click;
|
||||||
item.click = (itemClicked) => {
|
item.click = (itemClicked) => {
|
||||||
ogOnclick(itemClicked);
|
ogOnclick(itemClicked);
|
||||||
|
|||||||
Reference in New Issue
Block a user