mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
WIP 2
This commit is contained in:
@ -8,9 +8,9 @@ import { BackendContext } from '@/types/contexts';
|
||||
import config from '@/config';
|
||||
import { startPlugin, stopPlugin } from '@/utils';
|
||||
|
||||
const loadedPluginMap: Record<string, PluginDef> = {};
|
||||
const loadedPluginMap: Record<string, PluginDef<unknown, unknown, unknown>> = {};
|
||||
|
||||
const createContext = (id: string, win: BrowserWindow): BackendContext => ({
|
||||
const createContext = (id: string, win: BrowserWindow): BackendContext<PluginConfig> => ({
|
||||
getConfig: () =>
|
||||
deepmerge(
|
||||
mainPlugins[id].config,
|
||||
@ -33,6 +33,9 @@ const createContext = (id: string, win: BrowserWindow): BackendContext => ({
|
||||
listener(...args);
|
||||
});
|
||||
},
|
||||
removeHandler: (event: string) => {
|
||||
ipcMain.removeHandler(event);
|
||||
}
|
||||
},
|
||||
|
||||
window: win,
|
||||
@ -123,7 +126,7 @@ export const unloadAllMainPlugins = (win: BrowserWindow) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getLoadedMainPlugin = (id: string): PluginDef | undefined => {
|
||||
export const getLoadedMainPlugin = (id: string): PluginDef<unknown, unknown, unknown> | undefined => {
|
||||
return loadedPluginMap[id];
|
||||
};
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ export const loadAllMenuPlugins = (win: BrowserWindow) => {
|
||||
const pluginConfigs = config.plugins.getPlugins();
|
||||
|
||||
for (const [pluginId, pluginDef] of Object.entries(allPlugins)) {
|
||||
const config = deepmerge(pluginDef.config, pluginConfigs[pluginId] ?? {}) as PluginConfig;
|
||||
const config = deepmerge(pluginDef.config, pluginConfigs[pluginId] ?? {});
|
||||
|
||||
if (config.enabled) {
|
||||
forceLoadMenuPlugin(pluginId, win);
|
||||
|
||||
@ -25,6 +25,9 @@ const createContext = <Config extends PluginConfig>(id: string): RendererContext
|
||||
listener(...args);
|
||||
});
|
||||
},
|
||||
removeAllListeners: (event: string) => {
|
||||
window.ipcRenderer.removeAllListeners(event);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user