mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
refactor and stylecheck
This commit is contained in:
3
menu.js
3
menu.js
@ -147,7 +147,6 @@ const mainMenuTemplate = (win) => [
|
|||||||
label: "Proxy",
|
label: "Proxy",
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
checked: !!config.get("options.proxy"),
|
checked: !!config.get("options.proxy"),
|
||||||
//fixed: true, //skip in-app-menu click() override
|
|
||||||
click: (item) => {
|
click: (item) => {
|
||||||
setProxy(item, win);
|
setProxy(item, win);
|
||||||
}
|
}
|
||||||
@ -310,7 +309,6 @@ module.exports.setApplicationMenu = (win) => {
|
|||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
const iconPath = path.join(__dirname, "assets", "youtube-music-tray.png");
|
const iconPath = path.join(__dirname, "assets", "youtube-music-tray.png");
|
||||||
function setProxy(item, win) {
|
function setProxy(item, win) {
|
||||||
prompt({
|
prompt({
|
||||||
@ -326,7 +324,6 @@ function setProxy(item, win) {
|
|||||||
})
|
})
|
||||||
.then((input) => {
|
.then((input) => {
|
||||||
if(input !== null) {
|
if(input !== null) {
|
||||||
console.log(`setting proxy to ${input}`);
|
|
||||||
config.set("options.proxy", input);
|
config.set("options.proxy", input);
|
||||||
if(input === "")
|
if(input === "")
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
|
|||||||
@ -9,6 +9,8 @@ const { injectCSS } = require("../utils");
|
|||||||
|
|
||||||
//check that menu doesn't get created twice
|
//check that menu doesn't get created twice
|
||||||
let done = false;
|
let done = false;
|
||||||
|
//tracks menu visibility
|
||||||
|
let visible = true;
|
||||||
// win hook for fixing menu
|
// win hook for fixing menu
|
||||||
let win;
|
let win;
|
||||||
|
|
||||||
@ -41,17 +43,22 @@ module.exports = (winImport) => {
|
|||||||
|
|
||||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||||
if (config.get("options.hideMenu")) {
|
if (config.get("options.hideMenu")) {
|
||||||
switchMenuVisibility();
|
visible = false;
|
||||||
electronLocalshortcut.register(win, "Esc", () => {
|
electronLocalshortcut.register(win, "Esc", () => {
|
||||||
switchMenuVisibility();
|
switchMenuVisibility();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// fix bug with menu not applying on start
|
||||||
|
setMenuVisibility(visible);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let visible = false;
|
|
||||||
function switchMenuVisibility() {
|
function switchMenuVisibility() {
|
||||||
visible = !visible;
|
setMenuVisibility(!visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMenuVisibility(value){
|
||||||
|
visible = value;
|
||||||
win.webContents.send("updateMenu", visible);
|
win.webContents.send("updateMenu", visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user