mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: add default config
This commit is contained in:
@ -103,7 +103,7 @@ if (is.windows()) {
|
||||
ipcMain.handle('get-main-plugin-names', () => Object.keys(mainPlugins));
|
||||
|
||||
const initHook = (win: BrowserWindow) => {
|
||||
ipcMain.handle('get-config', (_, id: keyof PluginBuilderList) => config.get(`plugins.${id}` as never) ?? pluginBuilders[id].config);
|
||||
ipcMain.handle('get-config', (_, id: keyof PluginBuilderList) => deepmerge(pluginBuilders[id].config, config.get(`plugins.${id}`)) as PluginBuilderList[typeof id]['config']);
|
||||
ipcMain.handle('set-config', (_, name: string, obj: object) => config.setPartial(`plugins.${name}`, obj));
|
||||
|
||||
config.watch((newValue) => {
|
||||
@ -148,7 +148,7 @@ async function loadPlugins(win: BrowserWindow) {
|
||||
Key extends keyof PluginBuilderList,
|
||||
Config extends PluginBaseConfig = PluginBuilderList[Key]['config'],
|
||||
>(name: Key): MainPluginContext<Config> => ({
|
||||
getConfig: () => config.get(`plugins.${name}`) as unknown as Config,
|
||||
getConfig: () => deepmerge(pluginBuilders[name].config, config.get(`plugins.${name}`)) as Config,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${name}`, newConfig);
|
||||
},
|
||||
|
||||
@ -2,6 +2,8 @@ import is from 'electron-is';
|
||||
import { app, BrowserWindow, clipboard, dialog, Menu } from 'electron';
|
||||
import prompt from 'custom-electron-prompt';
|
||||
|
||||
import { deepmerge as createDeepmerge } from '@fastify/deepmerge';
|
||||
|
||||
import { restart } from './providers/app-controls';
|
||||
import config from './config';
|
||||
import { startingPages } from './providers/extracted-data';
|
||||
@ -22,6 +24,8 @@ const inAppMenuActive = config.plugins.isEnabled('in-app-menu');
|
||||
|
||||
const betaPlugins = ['crossfade', 'lumiastream'];
|
||||
|
||||
const deepmerge = createDeepmerge();
|
||||
|
||||
const pluginEnabledMenu = (plugin: string, label = '', hasSubmenu = false, refreshMenu: (() => void ) | undefined = undefined): Electron.MenuItemConstructorOptions => ({
|
||||
label: label || plugin,
|
||||
type: 'checkbox',
|
||||
@ -52,7 +56,7 @@ export const mainMenuTemplate = async (win: BrowserWindow): Promise<MenuTemplate
|
||||
Key extends keyof PluginBuilderList,
|
||||
Config extends PluginBaseConfig = PluginBuilderList[Key]['config'],
|
||||
>(name: Key): MenuPluginContext<Config> => ({
|
||||
getConfig: () => config.get(`plugins.${name}`) as unknown as Config,
|
||||
getConfig: () => deepmerge(pluginBuilders[name].config, config.get(`plugins.${name}`)) as Config,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${name}`, newConfig);
|
||||
},
|
||||
|
||||
@ -17,7 +17,7 @@ const createContext = <
|
||||
Key extends keyof PluginBuilderList,
|
||||
Config extends PluginBaseConfig = PluginBuilderList[Key]['config'],
|
||||
>(name: Key): PluginContext<Config> => ({
|
||||
getConfig: () => config.get(`plugins.${name}`) as unknown as Config,
|
||||
getConfig: () => deepmerge(pluginBuilders[name].config, config.get(`plugins.${name}`)) as Config,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${name}`, newConfig);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user