Introduction

some functions of desktop applications need to be loaded when the software is started; The controller layer code is executed only when the front end sends a request.

Example

  1. const is = require('electron-is');
  2. const tray = require('../library/tray');
  3. const security = require('../library/security');
  4. const awaken = require('../library/awaken');
  5. /**
  6. * Preload module entry
  7. */
  8. module.exports = async (app) => {
  9. // Realized functional modules, which can be used and modified selectively
  10. tray.install(app);
  11. security.install(app);
  12. awaken.install(app);
  13. loadUpdate(app);
  14. }
  15. /**
  16. * Load automatic upgrade module
  17. */
  18. function loadUpdate (app) {
  19. const config = app.config.autoUpdate;
  20. if ( (is.windows() && config.windows) || (is.macOS() && config.macOS) || (is.linux() && config.linux) ) {
  21. const autoUpdater = require('../library/autoUpdater');
  22. autoUpdater.install();
  23. // Check for updates
  24. if (config.force) {
  25. autoUpdater.checkUpdate();
  26. }
  27. }
  28. }