index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. let packageName = "ui-creator";
  2. let fs = require('fire-fs');
  3. let path = require('fire-path');
  4. let Electron = require('electron');
  5. let configUtil = Editor.require('packages://' + packageName + '/core/config-util.js');
  6. let projectPath = Editor.Project.path;
  7. Editor.Panel.extend({
  8. style: fs.readFileSync(Editor.url('packages://' + packageName + '/panel/index.css', 'utf8')) + "",
  9. template: fs.readFileSync(Editor.url('packages://' + packageName + '/panel/index.html', 'utf8')) + "",
  10. ready() {
  11. new window.Vue({
  12. el: this.shadowRoot,
  13. init() {
  14. },
  15. created() {
  16. this._initConfig();
  17. },
  18. data: {
  19. nodeOutputPath: null,
  20. uiOutputPath: null,
  21. },
  22. methods: {
  23. _initConfig() {
  24. configUtil.initCfg((data) => {
  25. this.nodeOutputPath = data.nodeOutputPath;
  26. this.uiOutputPath = data.uiOutputPath;
  27. });
  28. },
  29. _saveConfig() {
  30. let data = {
  31. nodeOutputPath: this.nodeOutputPath,
  32. uiOutputPath: this.uiOutputPath
  33. };
  34. configUtil.saveCfg(data);
  35. },
  36. onBtnSelectNodePath() {
  37. let res = Editor.Dialog.openFile({
  38. title: "选择UI节点树脚本输出路径",
  39. defaultPath: projectPath,
  40. properties: ['openDirectory'],
  41. });
  42. if (res !== -1) {
  43. let dir = res[0];
  44. if (dir !== this.nodeOutputPath) {
  45. this.nodeOutputPath = dir;
  46. }
  47. }
  48. },
  49. onBtnOpenNodePath() {
  50. let fullPath = path.join(projectPath, this.nodeOutputPath);
  51. if (fs.existsSync(fullPath)) {
  52. Electron.shell.showItemInFolder(fullPath);
  53. Electron.shell.beep();
  54. }
  55. },
  56. onBtnSelectUIPath() {
  57. let res = Editor.Dialog.openFile({
  58. title: "选择UI逻辑脚本输出路径",
  59. defaultPath: projectPath,
  60. properties: ['openDirectory'],
  61. });
  62. if (res !== -1) {
  63. let dir = res[0];
  64. if (dir !== this.uiOutputPath) {
  65. this.uiOutputPath = dir;
  66. }
  67. }
  68. },
  69. onBtnOpenUIPath() {
  70. let fullPath = path.join(projectPath, this.uiOutputPath);
  71. if (fs.existsSync(fullPath)) {
  72. Electron.shell.showItemInFolder(fullPath);
  73. Electron.shell.beep();
  74. }
  75. },
  76. }
  77. });
  78. }
  79. });