Add plugin system with sample plugin and settings UI
Introduces a plugin architecture, including a PluginManager, plugin loading in main and renderer processes, and a sample plugin demonstrating menu, IPC, and context menu contributions. Adds a Plugins tab to the settings UI for managing plugins (enable/disable, reload), and updates preload.js to load renderer preloads from plugins. Documentation for plugin development is included in README-PLUGINS.md.
This commit is contained in:
+24
-1
@@ -130,4 +130,27 @@ contextBridge.exposeInMainWorld('downloadsAPI', {
|
||||
onUpdated: (handler) => ipcRenderer.on('downloads-updated', (_e, payload) => handler(payload)),
|
||||
onDone: (handler) => ipcRenderer.on('downloads-done', (_e, payload) => handler(payload)),
|
||||
onCleared: (handler) => ipcRenderer.on('downloads-cleared', handler)
|
||||
});
|
||||
});
|
||||
|
||||
// ----------------------------------------
|
||||
// Plugin renderer preloads
|
||||
// ----------------------------------------
|
||||
// We request a list of absolute file paths from main and require() them here.
|
||||
// Each file can optionally call contextBridge.exposeInMainWorld to add APIs.
|
||||
(async () => {
|
||||
try {
|
||||
const preloads = await ipcRenderer.invoke('plugins-get-renderer-preloads');
|
||||
if (Array.isArray(preloads)) {
|
||||
for (const p of preloads) {
|
||||
try {
|
||||
// eslint-disable-next-line global-require, import/no-dynamic-require
|
||||
require(p);
|
||||
} catch (e) {
|
||||
console.error('[Plugins] Failed to load renderer preload:', p, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Plugins] No renderer preloads:', e);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user