event
You can define some callback functions in advance according to your needs, and Eagle will actively call them when events occur.
onPluginCreate(callback)
When the plugin window is created, Eagle will actively call this method. You can use this method to initialize the modules required by the plugin.
callbackFunctionpluginObject - Plugin attributesmanifestObject - The complete configuration of the plugin's manifest.json.pathString - The path where the plugin is located
eagle.onPluginCreate((plugin) => {
console.log(plugin.manifest.name);
console.log(plugin.manifest.version);
console.log(plugin.manifest.logo);
console.log(plugin.path);
});onPluginRun(callback)
When the user clicks on the plugin in the plugin panel, Eagle will actively call this method.
callbackFunction
eagle.onPluginRun(() => {
console.log('eagle.onPluginRun');
});onPluginBeforeExit(callback)
Before the plugin window closes, Eagle will actively call this method.
callbackFunction
eagle.onPluginBeforeExit(() => {
console.log("Plugin will exit");
});
// Prevent window from closing
window.onbeforeunload = (event) => {
return event.returnValue = false;
};onPluginShow(callback)
When the plugin window is displayed, Eagle will actively call this method.
callbackFunction
eagle.onPluginShow(() => {
console.log("Plugin window displayed");
});onPluginHide(callback)
When the plugin window is hidden, Eagle will actively call this method.
callbackFunction
eagle.onPluginHide(() => {
console.log("Plugin window hidden");
});onLibraryChanged(callback)
When the user switches the resource library, Eagle will actively call this method.
callbackFunctionlibraryPathString - The current resource library path.
eagle.onLibraryChanged((libraryPath) => {
console.log(`Resource library switch detected, new resource library path: ${libraryPath}`);
});Note: If the plugin execution process must rely on a relative resource library path, you may need to register this method and make corresponding adjustments when the resource library changes to avoid errors during program execution.
onThemeChanged(callback)
When the main program theme color of Eagle changes, Eagle will actively call this method. If the plugin supports multiple color themes, you can use this method to make corresponding UI adjustments.
callbackFunctionthemeString - The name of the current theme color, such asAuto,LIGHT,LIGHTGRAY,GRAY,DARK,BLUE,PURPLE.
eagle.onThemeChanged((theme) => {
console.log(`Color theme has changed to: ${theme}`);
});Last updated