@gct-paas/core 0.0.1-dev.26 → 0.0.1-dev.28

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.
@@ -1,8 +1,8 @@
1
1
  import path from '../../_virtual/index.mjs';
2
2
  import { PLUGIN_BASE_URL } from '../../constants/index.mjs';
3
3
  import '../../enums/index.mjs';
4
- import { PluginModeEnum } from '../../enums/plugin-enum.mjs';
5
4
  import { Platform } from '../../enums/page-designer/widget.mjs';
5
+ import { PluginModeEnum } from '../../enums/plugin-enum.mjs';
6
6
 
7
7
  "use strict";
8
8
  class PluginPgkUtil {
@@ -40,7 +40,13 @@ class PluginPgkUtil {
40
40
  if (this.cache.has(tag)) {
41
41
  return this.cache.get(tag);
42
42
  }
43
- const res = await _gct.api.platform.plugin.getGetTenantCompList();
43
+ const cfg = {
44
+ client: platform === Platform.WEB ? "WEB" : "MOBILE"
45
+ };
46
+ if (kit.length > 0) {
47
+ cfg.tag = kit.join(",");
48
+ }
49
+ const res = await _gct.api.platform.plugin.postGetTenantCompList(cfg);
44
50
  const configs = res.data;
45
51
  if (configs.length > 0) {
46
52
  this.cache.set(tag, configs);
@@ -54,17 +60,17 @@ class PluginPgkUtil {
54
60
  * @param {IStyleIMportMap[]} plugins
55
61
  * @returns {*} {Promise<System.Module[]>}
56
62
  */
57
- static async loadPlugins(mode, configs) {
63
+ static async loadPlugins(mode, configs = []) {
58
64
  const moduleMap = {};
59
65
  if (configs.length > 0) {
60
66
  const plugins = configs.map((plugin) => {
61
67
  const baseUrl = path.join(PLUGIN_BASE_URL, plugin.url, "dist");
62
68
  return {
63
69
  imports: {
64
- [plugin.key]: `${baseUrl}/${mode}.system.min.js`
70
+ [plugin.key]: `${baseUrl}/${mode}.system.min.js?version=${plugin.version}`
65
71
  },
66
72
  styles: {
67
- [plugin.key]: `${baseUrl}/${mode}.min.css`
73
+ [plugin.key]: `${baseUrl}/${mode}.min.css?version=${plugin.version}`
68
74
  }
69
75
  };
70
76
  });
@@ -156,54 +162,75 @@ class PluginPgkUtil {
156
162
  return [[], {}];
157
163
  }
158
164
  /**
159
- * 加载绘制态移动端插件包
165
+ * 加载设计态中,已经被从配置中移除的插件
166
+ *
167
+ * @static
168
+ * @param {Platform} platform
169
+ * @param {IObject[]} configs
170
+ * @returns {*} {Promise<void>}
171
+ */
172
+ static async loadDesignDeletedPlugins(platform, configs = []) {
173
+ try {
174
+ const moduleMap = await this.loadPlugins(PluginModeEnum.DESIGN, configs);
175
+ configs.forEach((config) => {
176
+ const plugins = config.plugins;
177
+ plugins.forEach((plugin) => {
178
+ const module = moduleMap[plugin.key];
179
+ if (platform === Platform.WEB) {
180
+ _gct.register.designer.web.register(
181
+ plugin.key,
182
+ () => new module.default()
183
+ );
184
+ } else {
185
+ _gct.register.designer.mobile.register(
186
+ plugin.key,
187
+ () => new module.default()
188
+ );
189
+ }
190
+ });
191
+ });
192
+ } catch (error) {
193
+ console.error(error);
194
+ }
195
+ }
196
+ /**
197
+ * 加载设计态移动端插件包
160
198
  *
161
199
  * @static
162
200
  * @param {App} app
163
- * @returns {*} {Promise<LoadPluginResult>}
201
+ * @param {IObject[]} configs 界面用到的插件集合
202
+ * @returns {*} {Promise<void>}
164
203
  */
165
- static async loadMobilePlugin(app, kit = []) {
204
+ static async loadMobilePlugin(app, configs = []) {
166
205
  try {
167
- const result = await this.loadPlugin(
168
- PluginModeEnum.MOBILE,
169
- Platform.MOBILE,
170
- kit
171
- );
172
- const [configs, moduleMap] = result;
206
+ const moduleMap = await this.loadPlugins(PluginModeEnum.MOBILE, configs);
173
207
  configs.forEach((config) => {
174
208
  const plugins = config.plugins;
175
209
  plugins.forEach((plugin) => {
176
210
  app.use(moduleMap[plugin.key].default);
177
211
  });
178
212
  });
179
- return result;
180
213
  } catch (error) {
181
214
  console.error(error);
182
215
  }
183
- return [[], {}];
184
216
  }
185
217
  /**
186
- * 加载绘制态网页端端插件包
218
+ * 加载设计态网页端插件包
187
219
  *
188
220
  * @static
189
221
  * @param {App} app
222
+ * @param {IObject[]} configs 界面用到的插件集合
190
223
  * @returns {*} {Promise<LoadPluginResult>}
191
224
  */
192
- static async loadWebPlugin(app, kit = []) {
225
+ static async loadWebPlugin(app, configs = []) {
193
226
  try {
194
- const result = await this.loadPlugin(
195
- PluginModeEnum.WEB,
196
- Platform.WEB,
197
- kit
198
- );
199
- const [configs, moduleMap] = result;
227
+ const moduleMap = await this.loadPlugins(PluginModeEnum.WEB, configs);
200
228
  configs.forEach((config) => {
201
229
  const plugins = config.plugins;
202
230
  plugins.forEach((plugin) => {
203
231
  app.use(moduleMap[plugin.key].default);
204
232
  });
205
233
  });
206
- return result;
207
234
  } catch (error) {
208
235
  console.error(error);
209
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.0.1-dev.26",
3
+ "version": "0.0.1-dev.28",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "main": "dist/index.min.cjs",
@@ -56,8 +56,8 @@
56
56
  "vue-i18n": "9.6.5"
57
57
  },
58
58
  "devDependencies": {
59
- "@gct-paas/build": "0.0.1-dev.26",
60
- "@gct-paas/cli": "0.0.1-dev.26",
59
+ "@gct-paas/build": "0.0.1-dev.28",
60
+ "@gct-paas/cli": "0.0.1-dev.28",
61
61
  "@types/path-browserify": "^1.0.3",
62
62
  "@types/qs": "^6.9.18",
63
63
  "fs-extra": "^11.3.0"
@@ -65,5 +65,5 @@
65
65
  "peerDependencies": {
66
66
  "vue": "^3.x"
67
67
  },
68
- "gitHead": "9cf5a8ec2d96167b764307bd52e291073cbd6476"
68
+ "gitHead": "1b551a067c28edb19d38da02baf56eb648784185"
69
69
  }