Plugin API
English
English
  • Getting Started
    • Introduction
    • Your First Plugin
    • File Structure Overview
    • Plugin Types
      • Window
      • Background Service
      • Format Extension
      • Inspector
    • Debug Plugin
  • Distribution
    • Prepare Plugin
    • Package Plugin
    • Publish Plugin
    • Update Plugin
    • Developer Policies
    • Plugin Icon Template
  • Developer Guide
    • manifest.json Configuration
    • Retrieve Data
    • Modify Data
    • Access Local Files
    • Issue Network Requests
    • Using Node.js Native API
    • Using Third-Party Modules
    • Multilingual (i18n)
    • Frameless Window
  • API Reference
    • event
    • item
    • folder
    • tag
    • tagGroup
    • library
    • window
    • app
    • os
    • screen
    • notification
    • contextMenu
    • dialog
    • clipboard
    • drag
    • shell
    • log
  • Extra Moudle
    • FFmpeg
Powered by GitBook
On this page
  1. Getting Started
  2. Plugin Types

Background Service

This article will describe the basic concepts of background service plugins.

PreviousWindowNextFormat Extension

Last updated 2 years ago

The development of background service plugins is similar to , with the main difference being the timing of code execution. Background service plugins will automatically start when the software starts, while window plugins will only execute when the user clicks on them. To create a background service plugin, simply add "serviceMode": true to the main field in the manifest.json, as shown below:

{
    "main":
    {
        "serviceMode": true,    // main difference
        "url": "index.html",
        "width": 640,
        "height": 480
    }
}

Background service plugins can also pop up windows, in which you can display the progress and status of the current background task, allowing users to clearly understand the current state of the plugin.

The final code is as follows:

{
    "id": "LBCZEHP8BBO94",
    "version": "1.0.0",
    "name": "Service Plugin",
    "logo": "/logo.png",
    "keywords": [],
    "main":
    {
        "serviceMode": true,
        "url": "index.html",
        "width": 640,
        "height": 480
    }
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <script type="text/javascript" src="js/plugin.js"></script>
</head>

<body>
    <div>Background services can be without UI, but you can still display the status of background services here.</div>
</body>
</html>
console.log(`Plugins will be created automatically, no need for users to execute them.`);

eagle.onPluginCreate((plugin) => {
    console.log('eagle.onPluginCreate');
    console.log(plugin);
});

eagle.onPluginShow(() => {
    console.log('eagle.onPluginShow');
});

eagle.onPluginHide(() => {
    console.log('eagle.onPluginHide');
});

Complete example code:

Note: You can refer to to learn about all the configuration methods for manifest.json

Note: If the plugin execution process relies on a relative resource library path, you may need to use to make corresponding adjustments when the resource library switches, avoiding errors during the program execution.

window plugins
https://github.com/eagle-app/eagle-plugin-examples/tree/main/Service
this article
onLibraryChanged(callback)