@gct-paas/core 0.0.1-dev.19 → 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";
@@ -5,7 +5,7 @@ export declare const STYLE_NAMESPACE_TAG = "gct";
5
5
  /**
6
6
  * 插件基础路径
7
7
  */
8
- export declare const PLUGIN_BASE_URL = "/minio/plugins";
8
+ export declare const PLUGIN_BASE_URL = "/minio";
9
9
  export { EditorRegisterConst } from './editor-register/editor-register';
10
10
  export { EditorType, EditorTypeOld } from './editor-type/editor-type';
11
11
  export { FormContainerType } from './form-container-type/form-container-type';
@@ -5,6 +5,6 @@ export { CoreConst } from './core.mjs';
5
5
 
6
6
  "use strict";
7
7
  const STYLE_NAMESPACE_TAG = "gct";
8
- const PLUGIN_BASE_URL = "/minio/plugins";
8
+ const PLUGIN_BASE_URL = "/minio";
9
9
 
10
10
  export { PLUGIN_BASE_URL, STYLE_NAMESPACE_TAG };
@@ -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,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import * as qs from 'qs';
2
+ import qs from 'qs';
3
3
  import { deepMerge } from '../tools/tools.mjs';
4
4
  import { interceptors } from './interceptors.mjs';
5
5
  import '../../enums/index.mjs';
@@ -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
- const baseUrl = path.join(PLUGIN_BASE_URL, plugin.name, "latest/dist");
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,48 +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) {
99
+ kit = ["common", ...kit];
88
100
  const tag = `${mode}-${platform}-${kit.join("_")}`;
89
101
  try {
90
102
  const configs = await this.loadPluginConfig(mode, platform);
91
- if (!this.cacheModule.has(tag)) {
103
+ if (!this.cacheModules.has(tag)) {
92
104
  const plugins = [];
93
105
  configs.forEach((cfg) => {
94
106
  if (cfg.plugins) {
95
107
  plugins.push(...cfg.plugins);
96
108
  }
97
109
  });
98
- const modules = await this.loadPlugins(mode, plugins);
99
- modules.forEach((module) => {
100
- if (module.default) {
101
- app.use(module.default);
102
- }
103
- });
104
- this.cacheModule.set(tag, modules);
110
+ const moduleMap = await this.loadPlugins(mode, plugins);
111
+ this.cacheModules.set(tag, moduleMap);
105
112
  }
106
- return configs;
113
+ return [configs, this.cacheModules.get(tag)];
107
114
  } catch (error) {
108
115
  console.error(error);
109
116
  }
110
- return [];
117
+ return [[], {}];
111
118
  }
112
119
  /**
113
120
  * 加载设计态插件包
@@ -115,30 +122,92 @@ class PluginPgkUtil {
115
122
  * @static
116
123
  * @param {App} app
117
124
  * @param {Platform} platform
118
- * @returns {*} {Promise<IObject[]>}
125
+ * @returns {*} {Promise<LoadPluginResult>}
119
126
  */
120
- static loadDesignPlugin(app, platform, kit = []) {
121
- 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 [[], {}];
122
157
  }
123
158
  /**
124
159
  * 加载绘制态移动端插件包
125
160
  *
126
161
  * @static
127
162
  * @param {App} app
128
- * @returns {*} {Promise<IObject[]>}
163
+ * @returns {*} {Promise<LoadPluginResult>}
129
164
  */
130
- static loadMobilePlugin(app, kit = []) {
131
- 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 [[], {}];
132
184
  }
133
185
  /**
134
186
  * 加载绘制态网页端端插件包
135
187
  *
136
188
  * @static
137
189
  * @param {App} app
138
- * @returns {*} {Promise<IObject[]>}
190
+ * @returns {*} {Promise<LoadPluginResult>}
139
191
  */
140
- static loadWebPlugin(app, kit = []) {
141
- 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 [[], {}];
142
211
  }
143
212
  }
144
213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.0.1-dev.19",
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.19",
60
- "@gct-paas/cli": "0.0.1-dev.19",
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": "37f06cee9864d6c619044900360504c50c865e89"
68
+ "gitHead": "37b40934f0d80ca67b4dba1c0259e8ca02f9dba5"
69
69
  }