Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement plugins into Electron app?

I'm looking for a way to implement "Plugins" for my Electron tool.

Below is a pseudo example of how I'm thinking it would work

Supply .js/.zip/plugin file

File would contain name of plugin, and it's category (Global, Team centric, Misc)

File would contain HTML for the GUI, which get's placed in a div designated for tool space. This name would be added as an option to the necessary Select, as well as logic added to pull in the HTML to the same div

In the tool, select the plugin file: page will load the JavaScript script, and add option to select along with logic to switch to the plugin

The hope is to automate my current process. Currently I'm manually updating the index page to reference the new JavaScript script, and to add the option on the select The JavaScript Script has logic in it looking at the Select, and looking to see if the option was selected which then pulls in it's own HTML via a function within

Is there anything I can reference/utilize to make this work?

like image 673
Marker Avatar asked Sep 12 '18 13:09

Marker


People also ask

Is Electron good for desktop apps?

With an improved runtime and great integration with JavaScript and Node. js, Electron JS makes both designing desktop apps and maintaining them on cross platforms easier and better.

Can you make Web apps with Electron?

It's easier than you thinkElectron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.

Do Electron apps need node?

Prerequisites​To use Electron, you need to install Node. js. We recommend that you use the latest LTS version available. Please install Node.


1 Answers

After 4+ months of working on this, I've managed to get this to work. I will try to outline my approach.

  • Each "plugin" or "tool" will need it's own .js file
  • the js file should contain an exports.html function that will return the html for the tool
  • the js file should contain an exports.Events function that adds all relevant event listeners
  • create a json file cataloging each tool, along with information needed i.e. a description, image path, .js file path, etc.
  • require the .js file when selected, load the html and the events
  • parse the json to figure out which tool to load along with needed info

all i need to do is update the json file and upload the .js file to add a new plugin.

like image 199
Marker Avatar answered Oct 04 '22 03:10

Marker