@ives_xxz/packages 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/AddComponent/main.js +32 -0
  2. package/AddComponent/package.json +26 -0
  3. package/AddComponent/panel/index.js +233 -0
  4. package/AddComponent/readme.md +38 -0
  5. package/AddComponent/scene-accessor.js +109 -0
  6. package/AddComponent/template-auto-dock.js +73 -0
  7. package/BitmapFontTools/i18n/en.js +1 -0
  8. package/BitmapFontTools/i18n/zh.js +1 -0
  9. package/BitmapFontTools/main.js +1 -0
  10. package/BitmapFontTools/package-lock.json +83 -0
  11. package/BitmapFontTools/package.json +37 -0
  12. package/BitmapFontTools/panel/font.css +1 -0
  13. package/BitmapFontTools/panel/font.js +58 -0
  14. package/BitmapFontTools/panel/font_panel.js +1 -0
  15. package/BitmapFontTools/panel/ttf.css +1 -0
  16. package/BitmapFontTools/panel/ttf.js +68 -0
  17. package/BitmapFontTools/panel/ttf_panel.js +1 -0
  18. package/FWAssetsFinder/main.js +9 -0
  19. package/FWAssetsFinder/package.json +20 -0
  20. package/FWAssetsFinder/panel/index.css +2 -0
  21. package/FWAssetsFinder/panel/index.html +52 -0
  22. package/FWAssetsFinder/panel/index.js +265 -0
  23. package/FWAssetsFinder/panel/less.css +71 -0
  24. package/FWAssetsFinder/panel/scene.js +194 -0
  25. package/FWExcelGenerator/main.js +367 -0
  26. package/FWExcelGenerator/package-lock.json +109 -0
  27. package/FWExcelGenerator/package.json +23 -0
  28. package/FWExcelGenerator/panel/index.js +648 -0
  29. package/FWLayerGenerator/main.js +186 -0
  30. package/FWLayerGenerator/package.json +21 -0
  31. package/FWLayerGenerator/panel/index.css +36 -0
  32. package/FWLayerGenerator/panel/index.html +17 -0
  33. package/FWLayerGenerator/panel/index.js +29 -0
  34. package/FWMask/inspector.js +26 -0
  35. package/FWMask/main.js +16 -0
  36. package/FWMask/package.json +6 -0
  37. package/FWPolygonPoints/main.js +149 -0
  38. package/FWPolygonPoints/package.json +9 -0
  39. package/PNG Auto Compress/CHANGELOG.md +32 -0
  40. package/PNG Auto Compress/LICENSE +21 -0
  41. package/PNG Auto Compress/README.md +113 -0
  42. package/PNG Auto Compress/config-manager.js +72 -0
  43. package/PNG Auto Compress/i18n/en.js +14 -0
  44. package/PNG Auto Compress/i18n/zh.js +14 -0
  45. package/PNG Auto Compress/images/setting.png +0 -0
  46. package/PNG Auto Compress/jsconfig.json +1 -0
  47. package/PNG Auto Compress/main.js +377 -0
  48. package/PNG Auto Compress/package.json +41 -0
  49. package/PNG Auto Compress/panel.setting/index.css +13 -0
  50. package/PNG Auto Compress/panel.setting/index.html +51 -0
  51. package/PNG Auto Compress/panel.setting/index.js +124 -0
  52. package/PNG Auto Compress/pngquant/macos/COPYRIGHT +687 -0
  53. package/PNG Auto Compress/pngquant/macos/README.md +78 -0
  54. package/PNG Auto Compress/pngquant/macos/pngquant +0 -0
  55. package/PNG Auto Compress/pngquant/macos/pngquant-compat +0 -0
  56. package/PNG Auto Compress/pngquant/windows/COPYRIGHT +687 -0
  57. package/PNG Auto Compress/pngquant/windows/Drag PNG here to reduce palette automatically.bat +11 -0
  58. package/PNG Auto Compress/pngquant/windows/Drag PNG here to reduce palette to 256.bat +10 -0
  59. package/PNG Auto Compress/pngquant/windows/README.txt +78 -0
  60. package/PNG Auto Compress/pngquant/windows/pngquant.exe +0 -0
  61. package/PNG Auto Compress/typings/cocos/editor.d.ts +1053 -0
  62. package/PNG Auto Compress/utils/file-utils.js +67 -0
  63. package/Quick Finder/CHANGELOG.md +100 -0
  64. package/Quick Finder/LICENSE +21 -0
  65. package/Quick Finder/README.en.md +141 -0
  66. package/Quick Finder/README.md +149 -0
  67. package/Quick Finder/i18n/en.js +42 -0
  68. package/Quick Finder/i18n/zh.js +42 -0
  69. package/Quick Finder/images/assets/animation-clip.png +0 -0
  70. package/Quick Finder/images/assets/asset.png +0 -0
  71. package/Quick Finder/images/assets/atlas.png +0 -0
  72. package/Quick Finder/images/assets/audio-clip.png +0 -0
  73. package/Quick Finder/images/assets/auto-atlas.png +0 -0
  74. package/Quick Finder/images/assets/bitmap-font.png +0 -0
  75. package/Quick Finder/images/assets/buffer.png +0 -0
  76. package/Quick Finder/images/assets/coffeescript.png +0 -0
  77. package/Quick Finder/images/assets/component.png +0 -0
  78. package/Quick Finder/images/assets/css.png +0 -0
  79. package/Quick Finder/images/assets/dragonbones-atlas.png +0 -0
  80. package/Quick Finder/images/assets/folder.png +0 -0
  81. package/Quick Finder/images/assets/html.png +0 -0
  82. package/Quick Finder/images/assets/javascript.png +0 -0
  83. package/Quick Finder/images/assets/json.png +0 -0
  84. package/Quick Finder/images/assets/label-atlas.png +0 -0
  85. package/Quick Finder/images/assets/markdown.png +0 -0
  86. package/Quick Finder/images/assets/material.png +0 -0
  87. package/Quick Finder/images/assets/mesh.png +0 -0
  88. package/Quick Finder/images/assets/mount.png +0 -0
  89. package/Quick Finder/images/assets/node.png +0 -0
  90. package/Quick Finder/images/assets/particle.png +0 -0
  91. package/Quick Finder/images/assets/physics-material.png +0 -0
  92. package/Quick Finder/images/assets/prefab.png +0 -0
  93. package/Quick Finder/images/assets/raw-asset.png +0 -0
  94. package/Quick Finder/images/assets/scene.png +0 -0
  95. package/Quick Finder/images/assets/shader.png +0 -0
  96. package/Quick Finder/images/assets/skeleton.png +0 -0
  97. package/Quick Finder/images/assets/spine.png +0 -0
  98. package/Quick Finder/images/assets/sprite-animation.png +0 -0
  99. package/Quick Finder/images/assets/sprite-atlas.png +0 -0
  100. package/Quick Finder/images/assets/sprite-frame.png +0 -0
  101. package/Quick Finder/images/assets/text.png +0 -0
  102. package/Quick Finder/images/assets/tiled-map.png +0 -0
  103. package/Quick Finder/images/assets/ttf-font.png +0 -0
  104. package/Quick Finder/images/assets/typescript.png +0 -0
  105. package/Quick Finder/images/search.png +0 -0
  106. package/Quick Finder/images/settings.png +0 -0
  107. package/Quick Finder/images/update.png +0 -0
  108. package/Quick Finder/images/version.png +0 -0
  109. package/Quick Finder/jsconfig.json +17 -0
  110. package/Quick Finder/lib/node-fetch.js +1649 -0
  111. package/Quick Finder/lib/vue.global.prod.js +7 -0
  112. package/Quick Finder/package.json +45 -0
  113. package/Quick Finder/src/common/config-manager.js +122 -0
  114. package/Quick Finder/src/eazax/browser-util.js +61 -0
  115. package/Quick Finder/src/eazax/color-util.js +37 -0
  116. package/Quick Finder/src/eazax/css/cocos-class.css +202 -0
  117. package/Quick Finder/src/eazax/css/cocos-tag.css +197 -0
  118. package/Quick Finder/src/eazax/css/eazax-colors.css +18 -0
  119. package/Quick Finder/src/eazax/editor-main-kit.js +53 -0
  120. package/Quick Finder/src/eazax/editor-main-util.js +112 -0
  121. package/Quick Finder/src/eazax/editor-renderer-kit.js +26 -0
  122. package/Quick Finder/src/eazax/file-util.js +158 -0
  123. package/Quick Finder/src/eazax/i18n.js +36 -0
  124. package/Quick Finder/src/eazax/main-event.js +81 -0
  125. package/Quick Finder/src/eazax/package-util.js +47 -0
  126. package/Quick Finder/src/eazax/renderer-event.js +80 -0
  127. package/Quick Finder/src/eazax/updater.js +92 -0
  128. package/Quick Finder/src/eazax/version-util.js +61 -0
  129. package/Quick Finder/src/eazax/window-util.js +80 -0
  130. package/Quick Finder/src/main/finder.js +101 -0
  131. package/Quick Finder/src/main/index.js +155 -0
  132. package/Quick Finder/src/main/opener.js +95 -0
  133. package/Quick Finder/src/main/panel-manager.js +159 -0
  134. package/Quick Finder/src/renderer/search/index.css +222 -0
  135. package/Quick Finder/src/renderer/search/index.html +46 -0
  136. package/Quick Finder/src/renderer/search/index.js +348 -0
  137. package/Quick Finder/src/renderer/settings/index.css +101 -0
  138. package/Quick Finder/src/renderer/settings/index.html +86 -0
  139. package/Quick Finder/src/renderer/settings/index.js +219 -0
  140. package/Quick Finder/typings/cocos/editor.d.ts +1053 -0
  141. package/Quick Finder/typings/vue.d.ts +1 -0
  142. package/README.md +93 -0
  143. package/package.json +12 -0
  144. package/unpack plist/main.js +253 -0
  145. package/unpack plist/package.json +13 -0
  146. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/CHANGELOG.md +30 -0
  147. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/LICENSE +21 -0
  148. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/README.en.md +111 -0
  149. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/README.md +115 -0
  150. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/i18n/en.js +55 -0
  151. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/i18n/zh.js +55 -0
  152. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/search.png +0 -0
  153. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/settings.png +0 -0
  154. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/update.png +0 -0
  155. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/version.png +0 -0
  156. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/jsconfig.json +17 -0
  157. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/lib/node-fetch.js +1649 -0
  158. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/lib/vue.global.prod.js +7 -0
  159. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/package.json +44 -0
  160. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/common/config-manager.js +104 -0
  161. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/browser-util.js +61 -0
  162. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/color-util.js +37 -0
  163. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/cocos-class.css +201 -0
  164. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/cocos-tag.css +197 -0
  165. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/eazax-colors.css +18 -0
  166. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-main-kit.js +53 -0
  167. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-main-util.js +147 -0
  168. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-renderer-kit.js +26 -0
  169. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/file-util.js +158 -0
  170. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/i18n.js +36 -0
  171. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/main-event.js +81 -0
  172. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/package-util.js +47 -0
  173. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/renderer-event.js +80 -0
  174. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/updater.js +92 -0
  175. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/version-util.js +61 -0
  176. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/window-util.js +80 -0
  177. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/editor-api.js +90 -0
  178. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/finder.js +248 -0
  179. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/index.js +155 -0
  180. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/object-util.js +70 -0
  181. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/panel-manager.js +86 -0
  182. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/parser.js +161 -0
  183. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/printer.js +108 -0
  184. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.css +61 -0
  185. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.html +90 -0
  186. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.js +191 -0
  187. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/typings/cocos/editor.d.ts +1053 -0
  188. package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/typings/vue.d.ts +1 -0
@@ -0,0 +1,101 @@
1
+ const Path = require('path');
2
+ const { map } = require('../eazax/file-util');
3
+
4
+ /**
5
+ * 查找器
6
+ */
7
+ const Finder = {
8
+
9
+ /**
10
+ * 数据缓存
11
+ * @type {{ name: string, path: string, extname: string }[]}
12
+ */
13
+ caches: null,
14
+
15
+ /**
16
+ * 清除缓存
17
+ */
18
+ clearCaches() {
19
+ Finder.caches = null;
20
+ },
21
+
22
+ /**
23
+ * 收集项目中的文件信息
24
+ */
25
+ async collectFiles() {
26
+ const caches = Finder.caches = [];
27
+ // 文件处理函数
28
+ const handler = (path, stat) => {
29
+ // 过滤
30
+ if (Finder.filter(path)) {
31
+ const name = Path.basename(path),
32
+ extname = Path.extname(path);
33
+ caches.push({ name, path, extname });
34
+ }
35
+ }
36
+ // 遍历项目文件
37
+ const assetsPath = Path.join(Editor.Project.path, 'assets');
38
+ await map(assetsPath, handler);
39
+ },
40
+
41
+ /**
42
+ * 过滤文件
43
+ * @param {string} path 路径
44
+ * @returns {boolean}
45
+ */
46
+ filter(path) {
47
+ // 扩展名
48
+ const extname = Path.extname(path);
49
+ // 排除 meta 文件和没有扩展名的文件
50
+ if (extname === '.meta' || extname === '') {
51
+ return false;
52
+ }
53
+ // 可用
54
+ return true;
55
+ },
56
+
57
+ /**
58
+ * 获取项目中匹配关键词的文件
59
+ * @param {string} keyword 关键词
60
+ * @returns {{ name: string, path: string, extname: string, similarity: number }[]}
61
+ */
62
+ getMatchedFiles(keyword) {
63
+ // 处理正则公式符号
64
+ const components = keyword.split('');
65
+ for (let i = 0, l = components.length; i < l; i++) {
66
+ if (/[*.?+$^()\[\]{}|\\\/]/.test(components[i])) {
67
+ components[i] = '\\' + components[i];
68
+ }
69
+ }
70
+ // 正则匹配
71
+ // - (.*):每个关键字之间可以有任意个字符;
72
+ // - (?):懒惰模式,匹配尽可能少的字符;
73
+ // - (i):不区分大小写;
74
+ const pattern = components.join('.*?'),
75
+ regExp = new RegExp(pattern, 'i');
76
+ // 下面这行正则插入很炫酷,但是性能不好,耗时接近 split + join 的 10 倍
77
+ // const pattern = keyword.replace(/(?<=.)(.)/g, '.*$1');
78
+ // 查找并匹配
79
+ const caches = Finder.caches,
80
+ results = [];
81
+ if (caches) {
82
+ // 从缓存中查找
83
+ for (let i = 0, l = caches.length; i < l; i++) {
84
+ const { name, path, extname } = caches[i];
85
+ // 匹配
86
+ const match = name.match(regExp);
87
+ if (match) {
88
+ // 相似度
89
+ const similarity = match[0].length;
90
+ results.push({ name, path, extname, similarity });
91
+ }
92
+ }
93
+ // 排序(similarity 越小,匹配的长度越短,匹配度越高)
94
+ results.sort((a, b) => a.similarity - b.similarity);
95
+ }
96
+ return results;
97
+ },
98
+
99
+ };
100
+
101
+ module.exports = Finder;
@@ -0,0 +1,155 @@
1
+ const MainEvent = require('../eazax/main-event');
2
+ const EditorMainKit = require('../eazax/editor-main-kit');
3
+ const { checkUpdate } = require('../eazax/editor-main-util');
4
+ const { openRepository } = require('../eazax/package-util');
5
+ const ConfigManager = require('../common/config-manager');
6
+ const Finder = require('./finder');
7
+ const Opener = require('./opener');
8
+ const PanelManager = require('./panel-manager');
9
+
10
+ /**
11
+ * 生命周期:加载
12
+ */
13
+ function load() {
14
+ // 监听事件
15
+ EditorMainKit.register();
16
+ MainEvent.on('match', onMatchEvent);
17
+ MainEvent.on('open', onOpenEvent);
18
+ MainEvent.on('focus', onFocusEvent);
19
+ }
20
+
21
+ /**
22
+ * 生命周期:卸载
23
+ */
24
+ function unload() {
25
+ // 关闭搜索栏
26
+ PanelManager.closeSearchBar();
27
+ // 取消事件监听
28
+ EditorMainKit.unregister();
29
+ MainEvent.removeAllListeners('match');
30
+ MainEvent.removeAllListeners('open');
31
+ MainEvent.removeAllListeners('focus');
32
+ }
33
+
34
+ /**
35
+ * (渲染进程)关键词匹配事件回调
36
+ * @param {Electron.IpcMainEvent} event
37
+ * @param {string} keyword 关键词
38
+ */
39
+ function onMatchEvent(event, keyword) {
40
+ // 匹配结果
41
+ const results = Finder.getMatchedFiles(keyword);
42
+ // 返回结果给渲染进程
43
+ if (event.reply) {
44
+ MainEvent.reply(event, 'match-reply', results);
45
+ } else {
46
+ // 兼容 Electron 4.x 及以下版本
47
+ MainEvent.send(event.sender, 'match-reply', results);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * (渲染进程)打开文件事件回调
53
+ * @param {Electron.IpcMainEvent} event
54
+ * @param {string} path 路径
55
+ */
56
+ function onOpenEvent(event, path) {
57
+ // 打开文件
58
+ Opener.tryOpen(path);
59
+ // 关闭搜索栏
60
+ PanelManager.closeSearchBar();
61
+ }
62
+
63
+ /**
64
+ * (渲染进程)聚焦文件事件回调
65
+ * @param {Electron.IpcMainEvent} event
66
+ * @param {string} path 路径
67
+ */
68
+ function onFocusEvent(event, path) {
69
+ // 在资源管理器中显示并选中文件
70
+ const uuid = Opener.fspathToUuid(path);
71
+ Opener.focusOnFile(uuid);
72
+ }
73
+
74
+ /**
75
+ * 打开搜索栏
76
+ */
77
+ function openSearchBar() {
78
+ const options = {
79
+ /** 打开前 */
80
+ onBeforeOpen: async () => {
81
+ // 收集项目中的文件信息
82
+ await Finder.collectFiles();
83
+ // 发消息通知渲染进程(搜索栏)
84
+ if (PanelManager.search) {
85
+ const webContents = PanelManager.search.webContents;
86
+ MainEvent.send(webContents, 'data-update');
87
+ }
88
+ },
89
+ /** 关闭后 */
90
+ onClosed: () => {
91
+ // 清除缓存
92
+ Finder.clearCaches();
93
+ },
94
+ };
95
+ PanelManager.openSearchBar(options);
96
+ }
97
+
98
+ module.exports = {
99
+
100
+ /**
101
+ * 扩展消息
102
+ */
103
+ messages: {
104
+
105
+ /**
106
+ * 打开搜索栏
107
+ * @param {*} event
108
+ */
109
+ 'open-search-bar'(event) {
110
+ openSearchBar();
111
+ },
112
+
113
+ /**
114
+ * 打开设置面板
115
+ * @param {*} event
116
+ */
117
+ 'open-settings-panel'(event) {
118
+ PanelManager.openSettingsPanel();
119
+ },
120
+
121
+ /**
122
+ * 检查更新
123
+ * @param {*} event
124
+ */
125
+ 'menu-check-update'(event) {
126
+ checkUpdate(true);
127
+ },
128
+
129
+ /**
130
+ * 版本
131
+ * @param {*} event
132
+ */
133
+ 'menu-version'(event) {
134
+ openRepository();
135
+ },
136
+
137
+ /**
138
+ * 场景面板加载完成后
139
+ * @param {*} event
140
+ */
141
+ 'scene:ready'(event) {
142
+ // 自动检查更新
143
+ const config = ConfigManager.get();
144
+ if (config.autoCheckUpdate) {
145
+ checkUpdate(false);
146
+ }
147
+ },
148
+
149
+ },
150
+
151
+ load,
152
+
153
+ unload,
154
+
155
+ };
@@ -0,0 +1,95 @@
1
+ const Path = require('path');
2
+ const ConfigManager = require('../common/config-manager');
3
+
4
+ /**
5
+ * 文件打开器
6
+ */
7
+ const Opener = {
8
+
9
+ /**
10
+ * 尝试打开文件
11
+ * @param {string} path 路径
12
+ */
13
+ tryOpen(path) {
14
+ const extname = Path.extname(path),
15
+ uuid = Opener.fspathToUuid(path);
16
+ // 是否配置了快速打开
17
+ const { openable } = ConfigManager.cache;
18
+ if (openable.indexOf(extname) !== -1) {
19
+ Opener.open(extname, uuid);
20
+ }
21
+ // 聚焦到文件(不延迟的话打开预制体会报错)
22
+ setTimeout(() => Opener.focusOnFile(uuid));
23
+ },
24
+
25
+ /**
26
+ * 打开文件
27
+ * @param {string} extname 扩展名
28
+ * @param {string} uuid Uuid
29
+ */
30
+ open(extname, uuid) {
31
+ switch (extname) {
32
+ case '.fire': {
33
+ Opener.openScene(uuid);
34
+ break;
35
+ }
36
+ case '.prefab': {
37
+ Opener.openPrefab(uuid);
38
+ break;
39
+ }
40
+ case '.ts':
41
+ case '.js':
42
+ case '.json':
43
+ case '.txt':
44
+ case '.md': {
45
+ Opener.openText(uuid);
46
+ break;
47
+ }
48
+ }
49
+ },
50
+
51
+ /**
52
+ * 打开场景
53
+ * @param {string} uuid Uuid
54
+ */
55
+ openScene(uuid) {
56
+ Editor.Panel.open('scene', { uuid });
57
+ },
58
+
59
+ /**
60
+ * 打开预制体
61
+ * @param {string} uuid Uuid
62
+ */
63
+ openPrefab(uuid) {
64
+ Editor.Ipc.sendToAll('scene:enter-prefab-edit-mode', uuid);
65
+ },
66
+
67
+ /**
68
+ * 打开文本文件
69
+ * @param {string} uuid Uuid
70
+ */
71
+ openText(uuid) {
72
+ Editor.Ipc.sendToMain('assets:open-text-file', uuid);
73
+ },
74
+
75
+ /**
76
+ * 聚焦到文件(在资源管理器中显示并选中文件)
77
+ * @param {string} uuid Uuid
78
+ */
79
+ focusOnFile(uuid) {
80
+ Editor.Ipc.sendToAll('assets:hint', uuid);
81
+ Editor.Selection.select('asset', uuid);
82
+ },
83
+
84
+ /**
85
+ * 通过绝对路径获取 uuid
86
+ * @param {string} path 路径
87
+ * @returns {string}
88
+ */
89
+ fspathToUuid(path) {
90
+ return Editor.assetdb.fspathToUuid(path);
91
+ },
92
+
93
+ };
94
+
95
+ module.exports = Opener;
@@ -0,0 +1,159 @@
1
+ const { BrowserWindow } = require('electron');
2
+ const { join } = require('path');
3
+ const { language, translate } = require('../eazax/editor-main-util');
4
+ const { calcWindowPosition } = require('../eazax/window-util');
5
+
6
+ /** 扩展名称 */
7
+ const EXTENSION_NAME = translate('name');
8
+
9
+ /**
10
+ * 面板管理器 (主进程)
11
+ */
12
+ const PanelManager = {
13
+
14
+ /**
15
+ * 搜索栏实例
16
+ * @type {BrowserWindow}
17
+ */
18
+ search: null,
19
+
20
+ /**
21
+ * 打开搜索栏
22
+ * @param {{ onBeforeOpen: () => void, onClosed: () => void }} options
23
+ */
24
+ openSearchBar(options) {
25
+ // 已打开则关闭
26
+ if (PanelManager.search) {
27
+ PanelManager.closeSearchBar();
28
+ return;
29
+ }
30
+ // 收集项目中的文件信息
31
+ options.onBeforeOpen();
32
+ // 窗口尺寸和位置(macOS 标题栏高 28px)
33
+ const winSize = [550, 550],
34
+ winPos = calcWindowPosition(winSize, 'top');
35
+ // 创建窗口
36
+ const win = PanelManager.search = new BrowserWindow({
37
+ width: winSize[0],
38
+ height: winSize[1],
39
+ x: winPos[0],
40
+ y: winPos[1] + 200,
41
+ frame: false,
42
+ resizable: false,
43
+ fullscreenable: false,
44
+ skipTaskbar: true,
45
+ alwaysOnTop: true,
46
+ transparent: true,
47
+ opacity: 0.95,
48
+ backgroundColor: '#00000000',
49
+ hasShadow: false,
50
+ show: false,
51
+ webPreferences: {
52
+ nodeIntegration: true,
53
+ contextIsolation: false,
54
+ },
55
+ });
56
+ // 就绪后展示(避免闪烁)
57
+ win.on('ready-to-show', () => win.show());
58
+ // 失焦后
59
+ win.on('blur', () => PanelManager.closeSearchBar());
60
+ // 关闭后
61
+ win.on('closed', () => {
62
+ PanelManager.search = null;
63
+ options.onClosed();
64
+ });
65
+ // 监听按键
66
+ win.webContents.on('before-input-event', (event, input) => {
67
+ if (input.key === 'Escape') PanelManager.closeSearchBar();
68
+ });
69
+ // 调试用的 devtools
70
+ // win.webContents.openDevTools({ mode: 'detach' });
71
+ // 加载页面
72
+ const path = join(__dirname, '../renderer/search/index.html');
73
+ win.loadURL(`file://${path}?lang=${language}`);
74
+ },
75
+
76
+ /**
77
+ * 关闭搜索栏
78
+ */
79
+ closeSearchBar() {
80
+ if (!PanelManager.search) {
81
+ return;
82
+ }
83
+ PanelManager.search.hide();
84
+ PanelManager.search.close();
85
+ PanelManager.search = null;
86
+ },
87
+
88
+ /**
89
+ * 面板实例
90
+ * @type {BrowserWindow}
91
+ */
92
+ settings: null,
93
+
94
+ /**
95
+ * 打开设置面板
96
+ */
97
+ openSettingsPanel() {
98
+ // 已打开则直接展示
99
+ if (PanelManager.settings) {
100
+ PanelManager.settings.show();
101
+ return;
102
+ }
103
+ // 窗口尺寸和位置(macOS 标题栏高 28px)
104
+ const winSize = [500, 450],
105
+ winPos = calcWindowPosition(winSize, 'center');
106
+ // 创建窗口
107
+ const win = PanelManager.settings = new BrowserWindow({
108
+ width: winSize[0],
109
+ height: winSize[1],
110
+ minWidth: winSize[0],
111
+ minHeight: winSize[1],
112
+ x: winPos[0],
113
+ y: winPos[1] - 100,
114
+ frame: true,
115
+ title: `${EXTENSION_NAME} | Cocos Creator`,
116
+ autoHideMenuBar: true,
117
+ resizable: true,
118
+ minimizable: false,
119
+ maximizable: false,
120
+ fullscreenable: false,
121
+ skipTaskbar: false,
122
+ alwaysOnTop: true,
123
+ hasShadow: true,
124
+ show: false,
125
+ webPreferences: {
126
+ nodeIntegration: true,
127
+ contextIsolation: false,
128
+ },
129
+ });
130
+ // 就绪后(展示,避免闪烁)
131
+ win.on('ready-to-show', () => win.show());
132
+ // 关闭后
133
+ win.on('closed', () => (PanelManager.settings = null));
134
+ // 监听按键
135
+ win.webContents.on('before-input-event', (event, input) => {
136
+ if (input.key === 'Escape') PanelManager.closeSettingsPanel();
137
+ });
138
+ // 调试用的 devtools
139
+ // win.webContents.openDevTools({ mode: 'detach' });
140
+ // 加载页面
141
+ const path = join(__dirname, '../renderer/settings/index.html');
142
+ win.loadURL(`file://${path}?lang=${language}`);
143
+ },
144
+
145
+ /**
146
+ * 关闭面板
147
+ */
148
+ closeSettingsPanel() {
149
+ if (!PanelManager.settings) {
150
+ return;
151
+ }
152
+ PanelManager.settings.hide();
153
+ PanelManager.settings.close();
154
+ PanelManager.settings = null;
155
+ },
156
+
157
+ };
158
+
159
+ module.exports = PanelManager;