index.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const Fs = require('fire-fs');
  2. const FsExtra = require('fs-extra');
  3. const Path = require('fire-path');
  4. const Electron = require('electron');
  5. const CfgUtil = Editor.require('packages://hot-update-tools/core/CfgUtil.js');
  6. const OSS = Editor.require('packages://hot-update-tools/node_modules/ali-oss');
  7. const GoogleAnalytics = Editor.require('packages://hot-update-tools/core/GoogleAnalytics.js');
  8. const OutPut = Editor.require('packages://hot-update-tools/core/OutPut.js');
  9. const Msg = Editor.require('packages://hot-update-tools/panel/msg.js');
  10. Editor.require('packages://hot-update-tools/panel/env-project.js');
  11. Editor.require('packages://hot-update-tools/panel/env-test.js');
  12. Editor.require('packages://hot-update-tools/panel/manifest-gen.js');
  13. Editor.Panel.extend({
  14. style: Fs.readFileSync(Editor.url('packages://hot-update-tools/panel/index.css'), 'utf8'),
  15. template: Fs.readFileSync(Editor.url('packages://hot-update-tools/panel/index.html'), 'utf8'),
  16. ready () {
  17. GoogleAnalytics.init();
  18. GoogleAnalytics.eventOpen();
  19. this.plugin = new window.Vue({
  20. el: this.shadowRoot,
  21. created () {
  22. CfgUtil.initCfg(this.log);
  23. this.$root.$on(Msg.Log, this.log);
  24. const data = Editor.require('packages://hot-update-tools/package.json');
  25. if (data) {
  26. this.version = `版本号:V${data.version}`;
  27. } else {
  28. this.version = '';
  29. }
  30. },
  31. data: {
  32. logView: '',
  33. version: '',
  34. },
  35. computed: {},
  36. methods: {
  37. log (str) {
  38. let time = new Date();
  39. this.logView += `[${time.toLocaleString()}]: ${str}\n`;
  40. this.$nextTick(() => {
  41. let logCtrl = this.$els.log;
  42. logCtrl.scrollTop = logCtrl.scrollHeight;
  43. });
  44. },
  45. onStopTouchEvent (event) {
  46. event.preventDefault();
  47. event.stopPropagation();
  48. },
  49. onBuildFinished (time) {
  50. // 当构建完成的时候,genTime和buildTime是一致的
  51. console.log('hot - onBuildFinished');
  52. },
  53. onTestSelect () {
  54. this.$nextTick(() => {
  55. this.$els.address.selectedIndex = index;
  56. });
  57. },
  58. },
  59. });
  60. },
  61. messages: {
  62. 'hot-update-tools:onBuildFinished' (event, time) {
  63. this.plugin.onBuildFinished(time);
  64. },
  65. },
  66. });