mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
feat: plugin auto-importer with vite-plugin-resolve (#1385)
This commit is contained in:
@ -3,7 +3,8 @@ import is from 'electron-is';
|
||||
|
||||
import config from './config';
|
||||
|
||||
import adblockerPreload from './plugins/adblocker/preload';
|
||||
// eslint-disable-next-line import/order
|
||||
import { pluginList as preloadPluginList } from 'virtual:PreloadPlugins';
|
||||
|
||||
import type { ConfigType, OneOfDefaultConfigKey } from './config/dynamic';
|
||||
|
||||
@ -15,15 +16,11 @@ export type PluginMapper<Type extends 'renderer' | 'preload' | 'backend'> = {
|
||||
)
|
||||
};
|
||||
|
||||
const preloadPlugins: PluginMapper<'preload'> = {
|
||||
'adblocker': adblockerPreload,
|
||||
};
|
||||
|
||||
const enabledPluginNameAndOptions = config.plugins.getEnabled();
|
||||
|
||||
enabledPluginNameAndOptions.forEach(async ([plugin, options]) => {
|
||||
if (Object.hasOwn(preloadPlugins, plugin)) {
|
||||
const handler = preloadPlugins[plugin];
|
||||
if (Object.hasOwn(preloadPluginList, plugin)) {
|
||||
const handler = preloadPluginList[plugin];
|
||||
try {
|
||||
await handler?.();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user