main.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const Package = require('./utils/package');
  3. const Fs = require('fire-fs');
  4. const Path = require('path');
  5. module.exports = {
  6. load () {
  7. Package.mount();
  8. },
  9. unload () {
  10. Package.unmount();
  11. },
  12. // register your ipc messages here
  13. messages: {
  14. 'open' () {
  15. // open entry panel registered in package.json
  16. Editor.Panel.open('i18n');
  17. Package.metrics();
  18. },
  19. 'import-asset' (event, path) {
  20. Editor.assetdb.refresh(path, (err, results) => {
  21. if (err) {
  22. Editor.assetdb.error('Failed to reimport asset %s, %s', path, err.stack);
  23. return;
  24. }
  25. Editor.assetdb._handleRefreshResults(results);
  26. let metaPath = path + '.meta';
  27. if (Fs.existsSync(Editor.url(metaPath))) {
  28. let meta = Fs.readJsonSync(Editor.url(metaPath));
  29. meta.isPlugin = true;
  30. Fs.outputJsonSync(Editor.url(metaPath), meta);
  31. } else {
  32. Editor.log('Failed to set language data file to plugin script');
  33. return;
  34. }
  35. });
  36. }
  37. },
  38. };