mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 04:11:47 +00:00
feat(in-app-menu): enable in-app-menu by default (in Windows) (#1311)
This commit is contained in:
@ -118,7 +118,12 @@ const defaultConfig = {
|
|||||||
playlistMaxItems: undefined as number | undefined,
|
playlistMaxItems: undefined as number | undefined,
|
||||||
},
|
},
|
||||||
'exponential-volume': {},
|
'exponential-volume': {},
|
||||||
'in-app-menu': {},
|
'in-app-menu': {
|
||||||
|
/**
|
||||||
|
* true in Windows, false in Linux and macOS (see youtube-music/config/store.ts)
|
||||||
|
*/
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
'last-fm': {
|
'last-fm': {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
token: undefined as string | undefined, // Token used for authentication
|
token: undefined as string | undefined, // Token used for authentication
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
import Store from 'electron-store';
|
import Store from 'electron-store';
|
||||||
import Conf from 'conf';
|
import Conf from 'conf';
|
||||||
|
import is from 'electron-is';
|
||||||
|
|
||||||
import defaults from './defaults';
|
import defaults from './defaults';
|
||||||
|
|
||||||
|
const getDefaults = () => {
|
||||||
|
if (is.windows()) {
|
||||||
|
defaults.plugins['in-app-menu'].enabled = true;
|
||||||
|
}
|
||||||
|
return defaults;
|
||||||
|
};
|
||||||
|
|
||||||
const setDefaultPluginOptions = (store: Conf<Record<string, unknown>>, plugin: keyof typeof defaults.plugins) => {
|
const setDefaultPluginOptions = (store: Conf<Record<string, unknown>>, plugin: keyof typeof defaults.plugins) => {
|
||||||
if (!store.get(`plugins.${plugin}`)) {
|
if (!store.get(`plugins.${plugin}`)) {
|
||||||
store.set(`plugins.${plugin}`, defaults.plugins[plugin]);
|
store.set(`plugins.${plugin}`, defaults.plugins[plugin]);
|
||||||
@ -118,7 +126,7 @@ const migrations = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default new Store({
|
export default new Store({
|
||||||
defaults,
|
defaults: getDefaults(),
|
||||||
clearInvalidConfig: false,
|
clearInvalidConfig: false,
|
||||||
migrations,
|
migrations,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -61,5 +61,7 @@ export default (win: BrowserWindow) => {
|
|||||||
ipcMain.handle('window-close', () => win.close());
|
ipcMain.handle('window-close', () => win.close());
|
||||||
ipcMain.handle('window-minimize', () => win.minimize());
|
ipcMain.handle('window-minimize', () => win.minimize());
|
||||||
ipcMain.handle('window-maximize', () => win.maximize());
|
ipcMain.handle('window-maximize', () => win.maximize());
|
||||||
|
win.on('maximize', () => win.webContents.send('window-maximize'));
|
||||||
ipcMain.handle('window-unmaximize', () => win.unmaximize());
|
ipcMain.handle('window-unmaximize', () => win.unmaximize());
|
||||||
|
win.on('unmaximize', () => win.webContents.send('window-unmaximize'));
|
||||||
};
|
};
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export default async () => {
|
|||||||
let hideMenu = config.get('options.hideMenu');
|
let hideMenu = config.get('options.hideMenu');
|
||||||
const titleBar = document.createElement('title-bar');
|
const titleBar = document.createElement('title-bar');
|
||||||
const navBar = document.querySelector<HTMLDivElement>('#nav-bar-background');
|
const navBar = document.querySelector<HTMLDivElement>('#nav-bar-background');
|
||||||
|
let maximizeButton: HTMLButtonElement;
|
||||||
if (isMacOS) titleBar.style.setProperty('--offset-left', '70px');
|
if (isMacOS) titleBar.style.setProperty('--offset-left', '70px');
|
||||||
|
|
||||||
logo.classList.add('title-bar-icon');
|
logo.classList.add('title-bar-icon');
|
||||||
@ -55,7 +56,7 @@ export default async () => {
|
|||||||
minimizeButton.appendChild(minimize);
|
minimizeButton.appendChild(minimize);
|
||||||
minimizeButton.onclick = () => ipcRenderer.invoke('window-minimize');
|
minimizeButton.onclick = () => ipcRenderer.invoke('window-minimize');
|
||||||
|
|
||||||
const maximizeButton = document.createElement('button');
|
maximizeButton = document.createElement('button');
|
||||||
if (await ipcRenderer.invoke('window-is-maximized')) {
|
if (await ipcRenderer.invoke('window-is-maximized')) {
|
||||||
maximizeButton.classList.add('window-control');
|
maximizeButton.classList.add('window-control');
|
||||||
maximizeButton.appendChild(unmaximize);
|
maximizeButton.appendChild(unmaximize);
|
||||||
@ -135,8 +136,14 @@ export default async () => {
|
|||||||
|
|
||||||
document.title = 'Youtube Music';
|
document.title = 'Youtube Music';
|
||||||
|
|
||||||
ipcRenderer.on('refreshMenu', () => {
|
ipcRenderer.on('refreshMenu', () => updateMenu());
|
||||||
updateMenu();
|
ipcRenderer.on('window-maximize', () => {
|
||||||
|
maximizeButton.removeChild(maximizeButton.firstChild!);
|
||||||
|
maximizeButton.appendChild(unmaximize);
|
||||||
|
});
|
||||||
|
ipcRenderer.on('window-unmaximize', () => {
|
||||||
|
maximizeButton.removeChild(maximizeButton.firstChild!);
|
||||||
|
maximizeButton.appendChild(maximize);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isEnabled('picture-in-picture')) {
|
if (isEnabled('picture-in-picture')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user