@gct-paas/core 0.0.1-dev.20 → 0.0.1-dev.21

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.
@@ -109,6 +109,10 @@ export declare enum EditorTypeOld {
109
109
  * 下拉选择编辑器
110
110
  */
111
111
  MODEL_SELECT = "model-editor",
112
+ /**
113
+ * 下拉字段编辑器
114
+ */
115
+ Field_SELECT = "field-editor",
112
116
  /**
113
117
  * 单选框编辑器
114
118
  */
@@ -27,6 +27,7 @@ var EditorTypeOld = /* @__PURE__ */ ((EditorTypeOld2) => {
27
27
  EditorTypeOld2["INFO"] = "info-editor";
28
28
  EditorTypeOld2["SELECT"] = "select-editor";
29
29
  EditorTypeOld2["MODEL_SELECT"] = "model-editor";
30
+ EditorTypeOld2["Field_SELECT"] = "field-editor";
30
31
  EditorTypeOld2["RADIO"] = "radio-editor";
31
32
  EditorTypeOld2["PICKER"] = "picker-editor";
32
33
  EditorTypeOld2["I18N"] = "i18n-editor";
@@ -56,6 +56,8 @@ export declare namespace LowCodeWidget {
56
56
  isReadonlyWidget?: boolean;
57
57
  /**部分组件嵌套在某个父组件内部 */
58
58
  parentComponent?: FormComponents;
59
+ /** 如果是插件,此处是拖入时插件的配置信息 */
60
+ _plugin?: IObject;
59
61
  }
60
62
  interface FieldSchema extends BasicSchema {
61
63
  props: FormItemProps & WidgetProps;
@@ -1,7 +1,7 @@
1
1
  export { HttpUtil } from './axios/axios';
2
2
  export { DictionaryUtil } from './dictionary/dictionary';
3
3
  export { Namespace } from './namespace/namespace';
4
- export { PluginPgkUtil } from './plugin-pkg-util/plugin-pkg-util';
4
+ export { PluginPgkUtil, type IModuleMap, type LoadPluginResult, } from './plugin-pkg-util/plugin-pkg-util';
5
5
  export { PluginStaticResource } from './plugin-static-resource/plugin-static-resource';
6
6
  export { deepMerge, getToken, setToken } from './tools/tools';
7
7
  export { widthEditorInstall } from './width-install/width-install';
@@ -1,5 +1,7 @@
1
1
  import { App } from 'vue';
2
2
  import { Platform } from '../../enums';
3
+ export type IModuleMap = Record<string, System.Module>;
4
+ export type LoadPluginResult = [IObject, IModuleMap];
3
5
  /**
4
6
  * 插件包处理工具类
5
7
  *
@@ -20,7 +22,13 @@ export declare class PluginPgkUtil {
20
22
  * @private
21
23
  * @static
22
24
  */
23
- private static cacheModule;
25
+ private static cacheModules;
26
+ /**
27
+ * 已经加载的插件与模块的映射
28
+ *
29
+ * @static
30
+ */
31
+ static readonly module: Map<string, System.Module>;
24
32
  /**
25
33
  * 加载插件包配置
26
34
  *
@@ -44,7 +52,6 @@ export declare class PluginPgkUtil {
44
52
  *
45
53
  * @private
46
54
  * @static
47
- * @param {App} app
48
55
  * @param {PluginModeEnum} mode
49
56
  * @param {Platform} platform
50
57
  * @returns {*}
@@ -56,23 +63,23 @@ export declare class PluginPgkUtil {
56
63
  * @static
57
64
  * @param {App} app
58
65
  * @param {Platform} platform
59
- * @returns {*} {Promise<IObject[]>}
66
+ * @returns {*} {Promise<LoadPluginResult>}
60
67
  */
61
- static loadDesignPlugin(app: App, platform: Platform, kit?: string[]): Promise<IObject[]>;
68
+ static loadDesignPlugin(_app: App, platform: Platform, kit?: string[]): Promise<LoadPluginResult>;
62
69
  /**
63
70
  * 加载绘制态移动端插件包
64
71
  *
65
72
  * @static
66
73
  * @param {App} app
67
- * @returns {*} {Promise<IObject[]>}
74
+ * @returns {*} {Promise<LoadPluginResult>}
68
75
  */
69
- static loadMobilePlugin(app: App, kit?: string[]): Promise<IObject[]>;
76
+ static loadMobilePlugin(app: App, kit?: string[]): Promise<LoadPluginResult>;
70
77
  /**
71
78
  * 加载绘制态网页端端插件包
72
79
  *
73
80
  * @static
74
81
  * @param {App} app
75
- * @returns {*} {Promise<IObject[]>}
82
+ * @returns {*} {Promise<LoadPluginResult>}
76
83
  */
77
- static loadWebPlugin(app: App, kit?: string[]): Promise<IObject[]>;
84
+ static loadWebPlugin(app: App, kit?: string[]): Promise<LoadPluginResult>;
78
85
  }
@@ -19,7 +19,13 @@ class PluginPgkUtil {
19
19
  * @private
20
20
  * @static
21
21
  */
22
- static cacheModule = /* @__PURE__ */ new Map();
22
+ static cacheModules = /* @__PURE__ */ new Map();
23
+ /**
24
+ * 已经加载的插件与模块的映射
25
+ *
26
+ * @static
27
+ */
28
+ static module = /* @__PURE__ */ new Map();
23
29
  /**
24
30
  * 加载插件包配置
25
31
  *
@@ -49,15 +55,16 @@ class PluginPgkUtil {
49
55
  * @returns {*} {Promise<System.Module[]>}
50
56
  */
51
57
  static async loadPlugins(mode, configs) {
58
+ const moduleMap = {};
52
59
  if (configs.length > 0) {
53
60
  const plugins = configs.map((plugin) => {
54
61
  const baseUrl = path.join(PLUGIN_BASE_URL, plugin.url, "dist");
55
62
  return {
56
63
  imports: {
57
- [plugin.name]: `${baseUrl}/${mode}.system.min.js`
64
+ [plugin.key]: `${baseUrl}/${mode}.system.min.js`
58
65
  },
59
66
  styles: {
60
- [plugin.name]: `${baseUrl}/${mode}.min.css`
67
+ [plugin.key]: `${baseUrl}/${mode}.min.css`
61
68
  }
62
69
  };
63
70
  });
@@ -66,49 +73,48 @@ class PluginPgkUtil {
66
73
  System.addImportMap(plugin);
67
74
  if (plugin.imports) {
68
75
  Object.keys(plugin.imports).forEach((key) => {
69
- all.push(System.import(key));
76
+ const load = async () => {
77
+ const module = await System.import(key);
78
+ moduleMap[key] = module;
79
+ this.module.set(key, module);
80
+ };
81
+ all.push(load());
70
82
  });
71
83
  }
72
84
  });
73
- return Promise.all(all);
85
+ await Promise.all(all);
74
86
  }
75
- return [];
87
+ return moduleMap;
76
88
  }
77
89
  /**
78
90
  * 加载插件包
79
91
  *
80
92
  * @private
81
93
  * @static
82
- * @param {App} app
83
94
  * @param {PluginModeEnum} mode
84
95
  * @param {Platform} platform
85
96
  * @returns {*}
86
97
  */
87
- static async loadPlugin(app, mode, platform, kit) {
98
+ static async loadPlugin(mode, platform, kit) {
88
99
  kit = ["common", ...kit];
89
100
  const tag = `${mode}-${platform}-${kit.join("_")}`;
90
101
  try {
91
102
  const configs = await this.loadPluginConfig(mode, platform);
92
- if (!this.cacheModule.has(tag)) {
103
+ if (!this.cacheModules.has(tag)) {
93
104
  const plugins = [];
94
105
  configs.forEach((cfg) => {
95
106
  if (cfg.plugins) {
96
107
  plugins.push(...cfg.plugins);
97
108
  }
98
109
  });
99
- const modules = await this.loadPlugins(mode, plugins);
100
- modules.forEach((module) => {
101
- if (module.default) {
102
- app.use(module.default);
103
- }
104
- });
105
- this.cacheModule.set(tag, modules);
110
+ const moduleMap = await this.loadPlugins(mode, plugins);
111
+ this.cacheModules.set(tag, moduleMap);
106
112
  }
107
- return configs;
113
+ return [configs, this.cacheModules.get(tag)];
108
114
  } catch (error) {
109
115
  console.error(error);
110
116
  }
111
- return [];
117
+ return [[], {}];
112
118
  }
113
119
  /**
114
120
  * 加载设计态插件包
@@ -116,30 +122,92 @@ class PluginPgkUtil {
116
122
  * @static
117
123
  * @param {App} app
118
124
  * @param {Platform} platform
119
- * @returns {*} {Promise<IObject[]>}
125
+ * @returns {*} {Promise<LoadPluginResult>}
120
126
  */
121
- static loadDesignPlugin(app, platform, kit = []) {
122
- return this.loadPlugin(app, PluginModeEnum.DESIGN, platform, kit);
127
+ static async loadDesignPlugin(_app, platform, kit = []) {
128
+ try {
129
+ const result = await this.loadPlugin(
130
+ PluginModeEnum.DESIGN,
131
+ platform,
132
+ kit
133
+ );
134
+ const [configs, moduleMap] = result;
135
+ configs.forEach((config) => {
136
+ const plugins = config.plugins;
137
+ plugins.forEach((plugin) => {
138
+ const module = moduleMap[plugin.key];
139
+ if (platform === Platform.WEB) {
140
+ _gct.register.designer.web.register(
141
+ plugin.key,
142
+ () => new module.default()
143
+ );
144
+ } else {
145
+ _gct.register.designer.mobile.register(
146
+ plugin.key,
147
+ () => new module.default()
148
+ );
149
+ }
150
+ });
151
+ });
152
+ return result;
153
+ } catch (error) {
154
+ console.error(error);
155
+ }
156
+ return [[], {}];
123
157
  }
124
158
  /**
125
159
  * 加载绘制态移动端插件包
126
160
  *
127
161
  * @static
128
162
  * @param {App} app
129
- * @returns {*} {Promise<IObject[]>}
163
+ * @returns {*} {Promise<LoadPluginResult>}
130
164
  */
131
- static loadMobilePlugin(app, kit = []) {
132
- return this.loadPlugin(app, PluginModeEnum.MOBILE, Platform.MOBILE, kit);
165
+ static async loadMobilePlugin(app, kit = []) {
166
+ try {
167
+ const result = await this.loadPlugin(
168
+ PluginModeEnum.MOBILE,
169
+ Platform.MOBILE,
170
+ kit
171
+ );
172
+ const [configs, moduleMap] = result;
173
+ configs.forEach((config) => {
174
+ const plugins = config.plugins;
175
+ plugins.forEach((plugin) => {
176
+ app.use(moduleMap[plugin.key].default);
177
+ });
178
+ });
179
+ return result;
180
+ } catch (error) {
181
+ console.error(error);
182
+ }
183
+ return [[], {}];
133
184
  }
134
185
  /**
135
186
  * 加载绘制态网页端端插件包
136
187
  *
137
188
  * @static
138
189
  * @param {App} app
139
- * @returns {*} {Promise<IObject[]>}
190
+ * @returns {*} {Promise<LoadPluginResult>}
140
191
  */
141
- static loadWebPlugin(app, kit = []) {
142
- return this.loadPlugin(app, PluginModeEnum.WEB, Platform.WEB, kit);
192
+ static async loadWebPlugin(app, kit = []) {
193
+ try {
194
+ const result = await this.loadPlugin(
195
+ PluginModeEnum.WEB,
196
+ Platform.WEB,
197
+ kit
198
+ );
199
+ const [configs, moduleMap] = result;
200
+ configs.forEach((config) => {
201
+ const plugins = config.plugins;
202
+ plugins.forEach((plugin) => {
203
+ app.use(moduleMap[plugin.key].default);
204
+ });
205
+ });
206
+ return result;
207
+ } catch (error) {
208
+ console.error(error);
209
+ }
210
+ return [[], {}];
143
211
  }
144
212
  }
145
213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.0.1-dev.20",
3
+ "version": "0.0.1-dev.21",
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.20",
60
- "@gct-paas/cli": "0.0.1-dev.20",
59
+ "@gct-paas/build": "0.0.1-dev.21",
60
+ "@gct-paas/cli": "0.0.1-dev.21",
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": "9266f204c9c400c60c3aeffe6981eed0992fc243"
68
+ "gitHead": "37b40934f0d80ca67b4dba1c0259e8ca02f9dba5"
69
69
  }