Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

38 rader
895 B

  1. let fileLister = require('../misc/fileLister');
  2. let events = require('../misc/events');
  3. const componentBase = require('./componentBase');
  4. let onReady = null;
  5. module.exports = {
  6. components: {},
  7. init: function (callback) {
  8. onReady = callback;
  9. events.emit('onBeforeGetComponents', this.components);
  10. this.getComponentFolder();
  11. },
  12. getComponentFolder: function () {
  13. const ignoreFiles = ['components.js', 'componentBase.js'];
  14. const files = fileLister.getFolder('./components/')
  15. .filter(f => !ignoreFiles.includes(f));
  16. const fLen = files.length;
  17. for (let i = 0; i < fLen; i++)
  18. this.getComponentFile(`./${files[i]}`);
  19. onReady();
  20. },
  21. getComponentFile: function (path) {
  22. let cpn = require(path);
  23. this.onGetComponent(cpn);
  24. },
  25. onGetComponent: function (template) {
  26. template = extend({}, componentBase, template);
  27. this.components[template.type] = template;
  28. }
  29. };