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