@pisell/core 1.0.15 → 1.0.16

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,50 +1,202 @@
1
- import App from "../app";
2
- import { LoadLibraryByUrlParams } from "../locales/type";
3
- import { MenuItem } from "../menuManager/index";
1
+ import App from '../app';
2
+ import { LoadLibraryByUrlParams } from '../locales/type';
3
+ import { MenuItem } from '../menuManager/index';
4
+ /**
5
+ * 应用接口类型定义
6
+ * @description 描述应用中单个页面、组件或功能的接口结构
7
+ */
4
8
  export declare type ApplicationInterface = {
5
- page_type: "low_code" | "code";
9
+ /** 页面类型:低代码或普通代码 */
10
+ page_type: 'low_code' | 'code';
11
+ /** 页面唯一标识 */
6
12
  page_id: number | string;
13
+ /** 页面code 优先使用 page_code 因为这个不会变, id在不同环境会变 */
7
14
  page_code: string;
15
+ /** 页面版本号,可选 */
8
16
  page_version?: string;
17
+ /** 页面显示名称, 这个会展示在tab标签页 */
9
18
  page_name: string;
10
- router: string;
11
- category: "page" | "component" | "function";
19
+ /** 路由地址, 可选 组件类型不使用这个 */
20
+ router?: string;
21
+ /** interface类别:页面、组件或功能 */
22
+ category: 'page' | 'component' | 'function';
23
+ /** React组件,可选, 不选使用低代码渲染 */
12
24
  Component?: any;
25
+ /** 子组件或子元素,可选, Layout会需要 */
13
26
  children?: any;
27
+ /** 布局模板,可选, 不选为默认layout */
14
28
  layout?: string;
29
+ /** 原始URL地址,可选 */
15
30
  originalUrl?: string;
31
+ autoRender?: boolean;
16
32
  };
33
+ /**
34
+ * 应用数据类型定义
35
+ * @description 描述完整应用的数据结构,包含应用的基本信息、接口、功能等
36
+ */
17
37
  export declare type ApplicationData = {
38
+ /** 应用唯一标识 */
18
39
  app_id: number;
40
+ /** 应用名称 */
19
41
  app_name: string;
20
- app_type: "system" | "custom";
42
+ /** 应用类型:系统应用或自定义应用 */
43
+ app_type: 'system' | 'custom';
44
+ /** 应用包含的接口列表 */
21
45
  interfaces: ApplicationInterface[];
46
+ /** 应用包含的功能列表,可选 */
22
47
  functions?: any[];
48
+ /** 应用的菜单配置 */
23
49
  menu?: {
24
50
  [key: string]: MenuItem[];
25
51
  };
52
+ /** 多语言配置,可选 */
26
53
  locales?: LoadLibraryByUrlParams;
54
+ /** 其他扩展属性 */
27
55
  [key: string]: any;
28
56
  };
57
+ /**
58
+ * 应用管理类
59
+ * @description 负责管理单个应用的生命周期,包括接口、组件、功能的初始化和管理
60
+ * @class Application
61
+ * @author zhiwei.Wang
62
+ */
29
63
  export declare class Application {
64
+ /** 应用配置数据 */
30
65
  options: ApplicationData;
31
- name: ApplicationData["app_name"];
32
- interfaces: Map<ApplicationInterface["page_name"], ApplicationInterface>;
66
+ /** 应用名称 */
67
+ name: ApplicationData['app_name'];
68
+ /** 应用内的页面接口映射表,以页面名称为键 */
69
+ interfaces: Map<ApplicationInterface['page_name'], ApplicationInterface>;
70
+ /** 应用内的组件映射表,以组件编码为键 */
33
71
  components: Map<string, any>;
72
+ /** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
34
73
  functions: Map<string, any>;
74
+ /** 应用实例引用 */
35
75
  app: App;
76
+ /**
77
+ * 构造函数
78
+ * @description 初始化应用实例,设置基本属性并初始化接口和功能
79
+ * @param {ApplicationData} options - 应用配置数据
80
+ * @param {App} app - 应用实例引用
81
+ */
36
82
  constructor(options: ApplicationData, app: App);
37
- afterAdd(application: Application): Promise<void>;
38
- beforeLoad(): Promise<void>;
39
- load(): Promise<void>;
40
- initInterfaces(interfaces: ApplicationData["interfaces"]): void;
41
- initFunctions(functions: ApplicationData["functions"]): void;
83
+ /**
84
+ * 应用添加后的内部处理方法
85
+ * @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
86
+ * @param {Application} application - 被添加的应用实例
87
+ * @returns {Promise<void>}
88
+ * @private
89
+ */
90
+ _afterAdd(application: Application): Promise<void>;
91
+ /**
92
+ * 应用加载前的内部处理方法
93
+ * @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
94
+ * @returns {Promise<void>}
95
+ * @private
96
+ */
97
+ _beforeLoad(): Promise<void>;
98
+ /**
99
+ * 应用加载的内部处理方法
100
+ * @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
101
+ * @returns {Promise<void>}
102
+ * @private
103
+ */
104
+ _load(): Promise<void>;
105
+ /**
106
+ * 初始化应用接口
107
+ * @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
108
+ * @param {ApplicationData['interfaces']} interfaces - 接口配置数组
109
+ * @returns {void}
110
+ */
111
+ initInterfaces(interfaces: ApplicationData['interfaces']): void;
112
+ /**
113
+ * 初始化应用功能函数
114
+ * @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
115
+ * @param {ApplicationData['functions']} functions - 功能配置数组,可选
116
+ * @returns {void}
117
+ */
118
+ initFunctions(functions: ApplicationData['functions']): void;
119
+ /**
120
+ * 加载接口组件
121
+ * @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
122
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
123
+ * @returns {Promise<ApplicationInterface>} 加载后的接口配置
124
+ */
42
125
  loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
126
+ /**
127
+ * 设置页面
128
+ * @description 将页面接口添加到接口映射表中
129
+ * @param {string} code - 页面编码
130
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
131
+ * @returns {void}
132
+ */
43
133
  setInterface(code: string, interfaceItem: ApplicationInterface): void;
134
+ /**
135
+ * 设置组件
136
+ * @description 将组件添加到组件映射表中
137
+ * @param {string} code - 组件编码
138
+ * @param {ApplicationInterface} component - 组件配置项
139
+ * @returns {void}
140
+ */
44
141
  setComponent(code: string, component: ApplicationInterface): void;
142
+ /**
143
+ * 设置功能函数
144
+ * @description 将功能函数添加到功能映射表中
145
+ * @param {string} code - 功能编码
146
+ * @param {ApplicationInterface} functionItem - 功能配置项
147
+ * @returns {void}
148
+ */
45
149
  setFunction(code: string, functionItem: ApplicationInterface): void;
150
+ /**
151
+ * 获取页面
152
+ * @description 根据编码从接口映射表中获取页面接口
153
+ * @param {string} code - 页面编码
154
+ * @returns {ApplicationInterface | undefined} 接口配置项或undefined
155
+ */
46
156
  getInterface(code: string): ApplicationInterface | undefined;
157
+ /**
158
+ * 获取组件
159
+ * @description 根据编码从组件映射表中获取组件
160
+ * @param {string} code - 组件编码
161
+ * @returns {any | undefined} 组件或undefined
162
+ */
47
163
  getComponent(code: string): any;
164
+ /**
165
+ * 获取功能函数
166
+ * @description 根据编码从功能映射表中获取功能函数
167
+ * @param {string} code - 功能编码
168
+ * @returns {any | undefined} 功能函数或undefined
169
+ */
48
170
  getFunction(code: string): any;
171
+ /**
172
+ * 执行功能函数
173
+ * @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
174
+ * @param {string} code - 功能编码
175
+ * @param {any} params - 传递给功能函数的参数对象,可选
176
+ * @param {...any} args - 传递给功能函数的其他参数
177
+ * @returns {any} 功能函数的执行结果
178
+ */
49
179
  runFunction(code: string, params?: any, ...args: any): any;
180
+ /**
181
+ * 应用添加后触发的钩子函数
182
+ * @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
183
+ * @param {Application} application - 被添加的应用实例
184
+ * @returns {Promise<void>}
185
+ * @author zhiwei.Wang
186
+ */
187
+ afterAdd(application: Application): Promise<void>;
188
+ /**
189
+ * 应用加载前触发的钩子函数
190
+ * @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
191
+ * @returns {Promise<void>}
192
+ * @author zhiwei.Wang
193
+ */
194
+ beforeLoad(application: Application): Promise<void>;
195
+ /**
196
+ * 应用加载完成后触发的钩子函数
197
+ * @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
198
+ * @returns {Promise<void>}
199
+ * @author zhiwei.Wang
200
+ */
201
+ load(application: Application): Promise<void>;
50
202
  }
@@ -10,17 +10,42 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ /**
14
+ * 应用接口类型定义
15
+ * @description 描述应用中单个页面、组件或功能的接口结构
16
+ */
17
+
18
+ /**
19
+ * 应用数据类型定义
20
+ * @description 描述完整应用的数据结构,包含应用的基本信息、接口、功能等
21
+ */
22
+
23
+ /**
24
+ * 应用管理类
25
+ * @description 负责管理单个应用的生命周期,包括接口、组件、功能的初始化和管理
26
+ * @class Application
27
+ * @author zhiwei.Wang
28
+ */
13
29
  export var Application = /*#__PURE__*/function () {
30
+ /**
31
+ * 构造函数
32
+ * @description 初始化应用实例,设置基本属性并初始化接口和功能
33
+ * @param {ApplicationData} options - 应用配置数据
34
+ * @param {App} app - 应用实例引用
35
+ */
14
36
  function Application(options, app) {
15
37
  _classCallCheck(this, Application);
38
+ /** 应用配置数据 */
16
39
  _defineProperty(this, "options", void 0);
40
+ /** 应用名称 */
17
41
  _defineProperty(this, "name", void 0);
18
- // 应用内的interface
42
+ /** 应用内的页面接口映射表,以页面名称为键 */
19
43
  _defineProperty(this, "interfaces", new Map());
20
- // 应用内的组件
44
+ /** 应用内的组件映射表,以组件编码为键 */
21
45
  _defineProperty(this, "components", new Map());
22
- // 应用内的函数, 比如跳转登录页面的方法
46
+ /** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
23
47
  _defineProperty(this, "functions", new Map());
48
+ /** 应用实例引用 */
24
49
  _defineProperty(this, "app", void 0);
25
50
  this.options = options;
26
51
  this.name = options.app_name;
@@ -28,67 +53,127 @@ export var Application = /*#__PURE__*/function () {
28
53
  this.initInterfaces(options.interfaces);
29
54
  this.initFunctions(options.functions);
30
55
  }
56
+
57
+ /**
58
+ * 应用添加后的内部处理方法
59
+ * @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
60
+ * @param {Application} application - 被添加的应用实例
61
+ * @returns {Promise<void>}
62
+ * @private
63
+ */
31
64
  _createClass(Application, [{
32
- key: "afterAdd",
33
- value: function () {
34
- var _afterAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(application) {
65
+ key: "_afterAdd",
66
+ value: (function () {
67
+ var _afterAdd2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(application) {
35
68
  return _regeneratorRuntime().wrap(function _callee$(_context) {
36
69
  while (1) switch (_context.prev = _context.next) {
37
70
  case 0:
38
71
  if (application.options.locales) {
39
72
  this.app.locales.loadLibraryByUrl(application.options.locales);
40
73
  }
41
- case 1:
74
+ _context.prev = 1;
75
+ _context.next = 4;
76
+ return this.afterAdd(this);
77
+ case 4:
78
+ _context.next = 9;
79
+ break;
80
+ case 6:
81
+ _context.prev = 6;
82
+ _context.t0 = _context["catch"](1);
83
+ console.log(_context.t0);
84
+ case 9:
42
85
  case "end":
43
86
  return _context.stop();
44
87
  }
45
- }, _callee, this);
88
+ }, _callee, this, [[1, 6]]);
46
89
  }));
47
- function afterAdd(_x) {
48
- return _afterAdd.apply(this, arguments);
90
+ function _afterAdd(_x) {
91
+ return _afterAdd2.apply(this, arguments);
49
92
  }
50
- return afterAdd;
93
+ return _afterAdd;
51
94
  }()
95
+ /**
96
+ * 应用加载前的内部处理方法
97
+ * @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
98
+ * @returns {Promise<void>}
99
+ * @private
100
+ */
101
+ )
52
102
  }, {
53
- key: "beforeLoad",
54
- value: function () {
55
- var _beforeLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
103
+ key: "_beforeLoad",
104
+ value: (function () {
105
+ var _beforeLoad2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
56
106
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
57
107
  while (1) switch (_context2.prev = _context2.next) {
58
108
  case 0:
109
+ _context2.prev = 0;
110
+ _context2.next = 3;
111
+ return this.beforeLoad(this);
112
+ case 3:
113
+ _context2.next = 8;
114
+ break;
115
+ case 5:
116
+ _context2.prev = 5;
117
+ _context2.t0 = _context2["catch"](0);
118
+ console.log(_context2.t0);
119
+ case 8:
59
120
  case "end":
60
121
  return _context2.stop();
61
122
  }
62
- }, _callee2);
123
+ }, _callee2, this, [[0, 5]]);
63
124
  }));
64
- function beforeLoad() {
65
- return _beforeLoad.apply(this, arguments);
125
+ function _beforeLoad() {
126
+ return _beforeLoad2.apply(this, arguments);
66
127
  }
67
- return beforeLoad;
128
+ return _beforeLoad;
68
129
  }()
130
+ /**
131
+ * 应用加载的内部处理方法
132
+ * @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
133
+ * @returns {Promise<void>}
134
+ * @private
135
+ */
136
+ )
69
137
  }, {
70
- key: "load",
71
- value: function () {
72
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
138
+ key: "_load",
139
+ value: (function () {
140
+ var _load2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
73
141
  var _this = this;
74
142
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
75
143
  while (1) switch (_context3.prev = _context3.next) {
76
144
  case 0:
145
+ _context3.prev = 0;
77
146
  // 将interface 生成路由
78
147
  this.interfaces.forEach(function (item, key) {
79
- _this.app.router.add(item.router, item);
148
+ _this.app.router.add((item === null || item === void 0 ? void 0 : item.router) || '', item);
80
149
  });
81
- case 1:
150
+ _context3.next = 4;
151
+ return this.load(this);
152
+ case 4:
153
+ _context3.next = 9;
154
+ break;
155
+ case 6:
156
+ _context3.prev = 6;
157
+ _context3.t0 = _context3["catch"](0);
158
+ console.log(_context3.t0);
159
+ case 9:
82
160
  case "end":
83
161
  return _context3.stop();
84
162
  }
85
- }, _callee3, this);
163
+ }, _callee3, this, [[0, 6]]);
86
164
  }));
87
- function load() {
88
- return _load.apply(this, arguments);
165
+ function _load() {
166
+ return _load2.apply(this, arguments);
89
167
  }
90
- return load;
168
+ return _load;
91
169
  }()
170
+ /**
171
+ * 初始化应用接口
172
+ * @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
173
+ * @param {ApplicationData['interfaces']} interfaces - 接口配置数组
174
+ * @returns {void}
175
+ */
176
+ )
92
177
  }, {
93
178
  key: "initInterfaces",
94
179
  value: function initInterfaces(interfaces) {
@@ -103,13 +188,13 @@ export var Application = /*#__PURE__*/function () {
103
188
  return _this2.loadInterface(interfaceItem);
104
189
  case 2:
105
190
  _interface = _context4.sent;
106
- if (interfaceItem.category === "page") {
191
+ if (interfaceItem.category === 'page') {
107
192
  _this2.setInterface(interfaceItem.page_code, _interface);
108
193
  }
109
- if (interfaceItem.category === "component") {
194
+ if (interfaceItem.category === 'component') {
110
195
  _this2.setComponent(interfaceItem.page_code, _interface);
111
196
  }
112
- if (interfaceItem.category === "function") {
197
+ if (interfaceItem.category === 'function') {
113
198
  _this2.setFunction(interfaceItem.page_code, _interface);
114
199
  }
115
200
  case 6:
@@ -123,6 +208,13 @@ export var Application = /*#__PURE__*/function () {
123
208
  };
124
209
  }());
125
210
  }
211
+
212
+ /**
213
+ * 初始化应用功能函数
214
+ * @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
215
+ * @param {ApplicationData['functions']} functions - 功能配置数组,可选
216
+ * @returns {void}
217
+ */
126
218
  }, {
127
219
  key: "initFunctions",
128
220
  value: function initFunctions(functions) {
@@ -144,9 +236,16 @@ export var Application = /*#__PURE__*/function () {
144
236
  };
145
237
  }());
146
238
  }
239
+
240
+ /**
241
+ * 加载接口组件
242
+ * @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
243
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
244
+ * @returns {Promise<ApplicationInterface>} 加载后的接口配置
245
+ */
147
246
  }, {
148
247
  key: "loadInterface",
149
- value: function () {
248
+ value: (function () {
150
249
  var _loadInterface = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(interfaceItem) {
151
250
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
152
251
  while (1) switch (_context6.prev = _context6.next) {
@@ -157,10 +256,10 @@ export var Application = /*#__PURE__*/function () {
157
256
  }
158
257
  return _context6.abrupt("return", interfaceItem);
159
258
  case 2:
160
- if (interfaceItem.page_type === "low_code") {
259
+ if (interfaceItem.page_type === 'low_code') {
161
260
  // TODO: load low code interface
162
261
  }
163
- if (interfaceItem.page_type === "code") {
262
+ if (interfaceItem.page_type === 'code') {
164
263
  // TODO: load code interface
165
264
  }
166
265
  return _context6.abrupt("return", interfaceItem);
@@ -175,36 +274,89 @@ export var Application = /*#__PURE__*/function () {
175
274
  }
176
275
  return loadInterface;
177
276
  }()
277
+ /**
278
+ * 设置页面
279
+ * @description 将页面接口添加到接口映射表中
280
+ * @param {string} code - 页面编码
281
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
282
+ * @returns {void}
283
+ */
284
+ )
178
285
  }, {
179
286
  key: "setInterface",
180
287
  value: function setInterface(code, interfaceItem) {
181
288
  this.interfaces.set(code, interfaceItem);
182
289
  }
290
+
291
+ /**
292
+ * 设置组件
293
+ * @description 将组件添加到组件映射表中
294
+ * @param {string} code - 组件编码
295
+ * @param {ApplicationInterface} component - 组件配置项
296
+ * @returns {void}
297
+ */
183
298
  }, {
184
299
  key: "setComponent",
185
300
  value: function setComponent(code, component) {
186
301
  this.components.set(code, component);
187
302
  }
303
+
304
+ /**
305
+ * 设置功能函数
306
+ * @description 将功能函数添加到功能映射表中
307
+ * @param {string} code - 功能编码
308
+ * @param {ApplicationInterface} functionItem - 功能配置项
309
+ * @returns {void}
310
+ */
188
311
  }, {
189
312
  key: "setFunction",
190
313
  value: function setFunction(code, functionItem) {
191
314
  this.functions.set(code, functionItem);
192
315
  }
316
+
317
+ /**
318
+ * 获取页面
319
+ * @description 根据编码从接口映射表中获取页面接口
320
+ * @param {string} code - 页面编码
321
+ * @returns {ApplicationInterface | undefined} 接口配置项或undefined
322
+ */
193
323
  }, {
194
324
  key: "getInterface",
195
325
  value: function getInterface(code) {
196
326
  return this.interfaces.get(code);
197
327
  }
328
+
329
+ /**
330
+ * 获取组件
331
+ * @description 根据编码从组件映射表中获取组件
332
+ * @param {string} code - 组件编码
333
+ * @returns {any | undefined} 组件或undefined
334
+ */
198
335
  }, {
199
336
  key: "getComponent",
200
337
  value: function getComponent(code) {
201
338
  return this.components.get(code);
202
339
  }
340
+
341
+ /**
342
+ * 获取功能函数
343
+ * @description 根据编码从功能映射表中获取功能函数
344
+ * @param {string} code - 功能编码
345
+ * @returns {any | undefined} 功能函数或undefined
346
+ */
203
347
  }, {
204
348
  key: "getFunction",
205
349
  value: function getFunction(code) {
206
350
  return this.functions.get(code);
207
351
  }
352
+ /**
353
+ * 执行功能函数
354
+ * @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
355
+ * @param {string} code - 功能编码
356
+ * @param {any} params - 传递给功能函数的参数对象,可选
357
+ * @param {...any} args - 传递给功能函数的其他参数
358
+ * @returns {any} 功能函数的执行结果
359
+ */
208
360
  }, {
209
361
  key: "runFunction",
210
362
  value: function runFunction(code, params) {
@@ -218,6 +370,79 @@ export var Application = /*#__PURE__*/function () {
218
370
  }
219
371
  return (_this$getFunction = this.getFunction(code)) === null || _this$getFunction === void 0 ? void 0 : _this$getFunction.code.apply(_this$getFunction, [_params].concat(args));
220
372
  }
373
+
374
+ /**
375
+ * 应用添加后触发的钩子函数
376
+ * @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
377
+ * @param {Application} application - 被添加的应用实例
378
+ * @returns {Promise<void>}
379
+ * @author zhiwei.Wang
380
+ */
381
+ }, {
382
+ key: "afterAdd",
383
+ value: (function () {
384
+ var _afterAdd3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(application) {
385
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
386
+ while (1) switch (_context7.prev = _context7.next) {
387
+ case 0:
388
+ case "end":
389
+ return _context7.stop();
390
+ }
391
+ }, _callee7);
392
+ }));
393
+ function afterAdd(_x5) {
394
+ return _afterAdd3.apply(this, arguments);
395
+ }
396
+ return afterAdd;
397
+ }()
398
+ /**
399
+ * 应用加载前触发的钩子函数
400
+ * @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
401
+ * @returns {Promise<void>}
402
+ * @author zhiwei.Wang
403
+ */
404
+ )
405
+ }, {
406
+ key: "beforeLoad",
407
+ value: (function () {
408
+ var _beforeLoad3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(application) {
409
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
410
+ while (1) switch (_context8.prev = _context8.next) {
411
+ case 0:
412
+ case "end":
413
+ return _context8.stop();
414
+ }
415
+ }, _callee8);
416
+ }));
417
+ function beforeLoad(_x6) {
418
+ return _beforeLoad3.apply(this, arguments);
419
+ }
420
+ return beforeLoad;
421
+ }()
422
+ /**
423
+ * 应用加载完成后触发的钩子函数
424
+ * @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
425
+ * @returns {Promise<void>}
426
+ * @author zhiwei.Wang
427
+ */
428
+ )
429
+ }, {
430
+ key: "load",
431
+ value: (function () {
432
+ var _load3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(application) {
433
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
434
+ while (1) switch (_context9.prev = _context9.next) {
435
+ case 0:
436
+ case "end":
437
+ return _context9.stop();
438
+ }
439
+ }, _callee9);
440
+ }));
441
+ function load(_x7) {
442
+ return _load3.apply(this, arguments);
443
+ }
444
+ return load;
445
+ }())
221
446
  }]);
222
447
  return Application;
223
448
  }();
@@ -1,5 +1,5 @@
1
- import APP from "../app";
2
- import { Application, ApplicationData } from "./application";
1
+ import APP from '../app';
2
+ import { Application, ApplicationData } from './application';
3
3
  export declare class ApplicationManager {
4
4
  applicationList: Application[];
5
5
  protected app: APP;
@@ -7,7 +7,12 @@ export declare class ApplicationManager {
7
7
  constructor(applicationList: Application[], app: APP);
8
8
  init(applicationList: Application[] | ApplicationData[]): Promise<unknown>;
9
9
  add(application: Application): Promise<void>;
10
- get(appName: Application["name"]): Application | undefined;
11
- remove(appName: Application["name"]): void;
10
+ get(appName: Application['name']): Application | undefined;
11
+ remove(appName: Application['name']): void;
12
12
  load(): Promise<void>;
13
+ /**
14
+ * 循环所有的应用, 找出所有的components进行渲染
15
+ * @returns
16
+ */
17
+ getAllComponents(): any[];
13
18
  }
@@ -43,7 +43,7 @@ export var ApplicationManager = /*#__PURE__*/function () {
43
43
  return _regeneratorRuntime().wrap(function _callee$(_context) {
44
44
  while (1) switch (_context.prev = _context.next) {
45
45
  case 0:
46
- if (_typeof(application) === "object") {
46
+ if (_typeof(application) === 'object') {
47
47
  application = new Application(application, _this.app);
48
48
  }
49
49
  _context.next = 3;
@@ -92,7 +92,7 @@ export var ApplicationManager = /*#__PURE__*/function () {
92
92
  case 0:
93
93
  this.applications.set(application.name, application);
94
94
  _context4.next = 3;
95
- return application.afterAdd(application);
95
+ return application._afterAdd(application);
96
96
  case 3:
97
97
  case "end":
98
98
  return _context4.stop();
@@ -119,7 +119,7 @@ export var ApplicationManager = /*#__PURE__*/function () {
119
119
  key: "load",
120
120
  value: function () {
121
121
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
122
- var _iterator, _step, plugin, _iterator2, _step2, _plugin;
122
+ var _iterator, _step, application, _iterator2, _step2, _application;
123
123
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
124
124
  while (1) switch (_context5.prev = _context5.next) {
125
125
  case 0:
@@ -131,9 +131,9 @@ export var ApplicationManager = /*#__PURE__*/function () {
131
131
  _context5.next = 9;
132
132
  break;
133
133
  }
134
- plugin = _step.value;
134
+ application = _step.value;
135
135
  _context5.next = 7;
136
- return plugin.beforeLoad();
136
+ return application._beforeLoad();
137
137
  case 7:
138
138
  _context5.next = 3;
139
139
  break;
@@ -157,9 +157,9 @@ export var ApplicationManager = /*#__PURE__*/function () {
157
157
  _context5.next = 26;
158
158
  break;
159
159
  }
160
- _plugin = _step2.value;
160
+ _application = _step2.value;
161
161
  _context5.next = 24;
162
- return _plugin.load();
162
+ return _application._load();
163
163
  case 24:
164
164
  _context5.next = 20;
165
165
  break;
@@ -185,6 +185,21 @@ export var ApplicationManager = /*#__PURE__*/function () {
185
185
  }
186
186
  return load;
187
187
  }()
188
+ /**
189
+ * 循环所有的应用, 找出所有的components进行渲染
190
+ * @returns
191
+ */
192
+ }, {
193
+ key: "getAllComponents",
194
+ value: function getAllComponents() {
195
+ return Array.from(this.applications.values()).flatMap(function (application) {
196
+ return Array.from(application.components.values());
197
+ }).filter(function (component) {
198
+ return component.autoRender;
199
+ }).map(function (component) {
200
+ return component.Component;
201
+ });
202
+ }
188
203
  }]);
189
204
  return ApplicationManager;
190
205
  }();
File without changes
File without changes
@@ -1,50 +1,202 @@
1
- import App from "../app";
2
- import { LoadLibraryByUrlParams } from "../locales/type";
3
- import { MenuItem } from "../menuManager/index";
1
+ import App from '../app';
2
+ import { LoadLibraryByUrlParams } from '../locales/type';
3
+ import { MenuItem } from '../menuManager/index';
4
+ /**
5
+ * 应用接口类型定义
6
+ * @description 描述应用中单个页面、组件或功能的接口结构
7
+ */
4
8
  export declare type ApplicationInterface = {
5
- page_type: "low_code" | "code";
9
+ /** 页面类型:低代码或普通代码 */
10
+ page_type: 'low_code' | 'code';
11
+ /** 页面唯一标识 */
6
12
  page_id: number | string;
13
+ /** 页面code 优先使用 page_code 因为这个不会变, id在不同环境会变 */
7
14
  page_code: string;
15
+ /** 页面版本号,可选 */
8
16
  page_version?: string;
17
+ /** 页面显示名称, 这个会展示在tab标签页 */
9
18
  page_name: string;
10
- router: string;
11
- category: "page" | "component" | "function";
19
+ /** 路由地址, 可选 组件类型不使用这个 */
20
+ router?: string;
21
+ /** interface类别:页面、组件或功能 */
22
+ category: 'page' | 'component' | 'function';
23
+ /** React组件,可选, 不选使用低代码渲染 */
12
24
  Component?: any;
25
+ /** 子组件或子元素,可选, Layout会需要 */
13
26
  children?: any;
27
+ /** 布局模板,可选, 不选为默认layout */
14
28
  layout?: string;
29
+ /** 原始URL地址,可选 */
15
30
  originalUrl?: string;
31
+ autoRender?: boolean;
16
32
  };
33
+ /**
34
+ * 应用数据类型定义
35
+ * @description 描述完整应用的数据结构,包含应用的基本信息、接口、功能等
36
+ */
17
37
  export declare type ApplicationData = {
38
+ /** 应用唯一标识 */
18
39
  app_id: number;
40
+ /** 应用名称 */
19
41
  app_name: string;
20
- app_type: "system" | "custom";
42
+ /** 应用类型:系统应用或自定义应用 */
43
+ app_type: 'system' | 'custom';
44
+ /** 应用包含的接口列表 */
21
45
  interfaces: ApplicationInterface[];
46
+ /** 应用包含的功能列表,可选 */
22
47
  functions?: any[];
48
+ /** 应用的菜单配置 */
23
49
  menu?: {
24
50
  [key: string]: MenuItem[];
25
51
  };
52
+ /** 多语言配置,可选 */
26
53
  locales?: LoadLibraryByUrlParams;
54
+ /** 其他扩展属性 */
27
55
  [key: string]: any;
28
56
  };
57
+ /**
58
+ * 应用管理类
59
+ * @description 负责管理单个应用的生命周期,包括接口、组件、功能的初始化和管理
60
+ * @class Application
61
+ * @author zhiwei.Wang
62
+ */
29
63
  export declare class Application {
64
+ /** 应用配置数据 */
30
65
  options: ApplicationData;
31
- name: ApplicationData["app_name"];
32
- interfaces: Map<ApplicationInterface["page_name"], ApplicationInterface>;
66
+ /** 应用名称 */
67
+ name: ApplicationData['app_name'];
68
+ /** 应用内的页面接口映射表,以页面名称为键 */
69
+ interfaces: Map<ApplicationInterface['page_name'], ApplicationInterface>;
70
+ /** 应用内的组件映射表,以组件编码为键 */
33
71
  components: Map<string, any>;
72
+ /** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
34
73
  functions: Map<string, any>;
74
+ /** 应用实例引用 */
35
75
  app: App;
76
+ /**
77
+ * 构造函数
78
+ * @description 初始化应用实例,设置基本属性并初始化接口和功能
79
+ * @param {ApplicationData} options - 应用配置数据
80
+ * @param {App} app - 应用实例引用
81
+ */
36
82
  constructor(options: ApplicationData, app: App);
37
- afterAdd(application: Application): Promise<void>;
38
- beforeLoad(): Promise<void>;
39
- load(): Promise<void>;
40
- initInterfaces(interfaces: ApplicationData["interfaces"]): void;
41
- initFunctions(functions: ApplicationData["functions"]): void;
83
+ /**
84
+ * 应用添加后的内部处理方法
85
+ * @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
86
+ * @param {Application} application - 被添加的应用实例
87
+ * @returns {Promise<void>}
88
+ * @private
89
+ */
90
+ _afterAdd(application: Application): Promise<void>;
91
+ /**
92
+ * 应用加载前的内部处理方法
93
+ * @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
94
+ * @returns {Promise<void>}
95
+ * @private
96
+ */
97
+ _beforeLoad(): Promise<void>;
98
+ /**
99
+ * 应用加载的内部处理方法
100
+ * @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
101
+ * @returns {Promise<void>}
102
+ * @private
103
+ */
104
+ _load(): Promise<void>;
105
+ /**
106
+ * 初始化应用接口
107
+ * @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
108
+ * @param {ApplicationData['interfaces']} interfaces - 接口配置数组
109
+ * @returns {void}
110
+ */
111
+ initInterfaces(interfaces: ApplicationData['interfaces']): void;
112
+ /**
113
+ * 初始化应用功能函数
114
+ * @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
115
+ * @param {ApplicationData['functions']} functions - 功能配置数组,可选
116
+ * @returns {void}
117
+ */
118
+ initFunctions(functions: ApplicationData['functions']): void;
119
+ /**
120
+ * 加载接口组件
121
+ * @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
122
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
123
+ * @returns {Promise<ApplicationInterface>} 加载后的接口配置
124
+ */
42
125
  loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
126
+ /**
127
+ * 设置页面
128
+ * @description 将页面接口添加到接口映射表中
129
+ * @param {string} code - 页面编码
130
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
131
+ * @returns {void}
132
+ */
43
133
  setInterface(code: string, interfaceItem: ApplicationInterface): void;
134
+ /**
135
+ * 设置组件
136
+ * @description 将组件添加到组件映射表中
137
+ * @param {string} code - 组件编码
138
+ * @param {ApplicationInterface} component - 组件配置项
139
+ * @returns {void}
140
+ */
44
141
  setComponent(code: string, component: ApplicationInterface): void;
142
+ /**
143
+ * 设置功能函数
144
+ * @description 将功能函数添加到功能映射表中
145
+ * @param {string} code - 功能编码
146
+ * @param {ApplicationInterface} functionItem - 功能配置项
147
+ * @returns {void}
148
+ */
45
149
  setFunction(code: string, functionItem: ApplicationInterface): void;
150
+ /**
151
+ * 获取页面
152
+ * @description 根据编码从接口映射表中获取页面接口
153
+ * @param {string} code - 页面编码
154
+ * @returns {ApplicationInterface | undefined} 接口配置项或undefined
155
+ */
46
156
  getInterface(code: string): ApplicationInterface | undefined;
157
+ /**
158
+ * 获取组件
159
+ * @description 根据编码从组件映射表中获取组件
160
+ * @param {string} code - 组件编码
161
+ * @returns {any | undefined} 组件或undefined
162
+ */
47
163
  getComponent(code: string): any;
164
+ /**
165
+ * 获取功能函数
166
+ * @description 根据编码从功能映射表中获取功能函数
167
+ * @param {string} code - 功能编码
168
+ * @returns {any | undefined} 功能函数或undefined
169
+ */
48
170
  getFunction(code: string): any;
171
+ /**
172
+ * 执行功能函数
173
+ * @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
174
+ * @param {string} code - 功能编码
175
+ * @param {any} params - 传递给功能函数的参数对象,可选
176
+ * @param {...any} args - 传递给功能函数的其他参数
177
+ * @returns {any} 功能函数的执行结果
178
+ */
49
179
  runFunction(code: string, params?: any, ...args: any): any;
180
+ /**
181
+ * 应用添加后触发的钩子函数
182
+ * @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
183
+ * @param {Application} application - 被添加的应用实例
184
+ * @returns {Promise<void>}
185
+ * @author zhiwei.Wang
186
+ */
187
+ afterAdd(application: Application): Promise<void>;
188
+ /**
189
+ * 应用加载前触发的钩子函数
190
+ * @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
191
+ * @returns {Promise<void>}
192
+ * @author zhiwei.Wang
193
+ */
194
+ beforeLoad(application: Application): Promise<void>;
195
+ /**
196
+ * 应用加载完成后触发的钩子函数
197
+ * @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
198
+ * @returns {Promise<void>}
199
+ * @author zhiwei.Wang
200
+ */
201
+ load(application: Application): Promise<void>;
50
202
  }
@@ -23,15 +23,24 @@ __export(application_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(application_exports);
25
25
  var Application = class {
26
+ /** 应用配置数据 */
26
27
  options;
28
+ /** 应用名称 */
27
29
  name;
28
- // 应用内的interface
30
+ /** 应用内的页面接口映射表,以页面名称为键 */
29
31
  interfaces = /* @__PURE__ */ new Map();
30
- // 应用内的组件
32
+ /** 应用内的组件映射表,以组件编码为键 */
31
33
  components = /* @__PURE__ */ new Map();
32
- // 应用内的函数, 比如跳转登录页面的方法
34
+ /** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
33
35
  functions = /* @__PURE__ */ new Map();
36
+ /** 应用实例引用 */
34
37
  app;
38
+ /**
39
+ * 构造函数
40
+ * @description 初始化应用实例,设置基本属性并初始化接口和功能
41
+ * @param {ApplicationData} options - 应用配置数据
42
+ * @param {App} app - 应用实例引用
43
+ */
35
44
  constructor(options, app) {
36
45
  this.options = options;
37
46
  this.name = options.app_name;
@@ -39,18 +48,58 @@ var Application = class {
39
48
  this.initInterfaces(options.interfaces);
40
49
  this.initFunctions(options.functions);
41
50
  }
42
- async afterAdd(application) {
51
+ /**
52
+ * 应用添加后的内部处理方法
53
+ * @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
54
+ * @param {Application} application - 被添加的应用实例
55
+ * @returns {Promise<void>}
56
+ * @private
57
+ */
58
+ async _afterAdd(application) {
43
59
  if (application.options.locales) {
44
60
  this.app.locales.loadLibraryByUrl(application.options.locales);
45
61
  }
62
+ try {
63
+ await this.afterAdd(this);
64
+ } catch (err) {
65
+ console.log(err);
66
+ }
46
67
  }
47
- async beforeLoad() {
68
+ /**
69
+ * 应用加载前的内部处理方法
70
+ * @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
71
+ * @returns {Promise<void>}
72
+ * @private
73
+ */
74
+ async _beforeLoad() {
75
+ try {
76
+ await this.beforeLoad(this);
77
+ } catch (err) {
78
+ console.log(err);
79
+ }
48
80
  }
49
- async load() {
50
- this.interfaces.forEach((item, key) => {
51
- this.app.router.add(item.router, item);
52
- });
81
+ /**
82
+ * 应用加载的内部处理方法
83
+ * @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
84
+ * @returns {Promise<void>}
85
+ * @private
86
+ */
87
+ async _load() {
88
+ try {
89
+ this.interfaces.forEach((item, key) => {
90
+ this.app.router.add((item == null ? void 0 : item.router) || "", item);
91
+ });
92
+ await this.load(this);
93
+ } catch (err) {
94
+ console.log(err);
95
+ }
53
96
  }
97
+ /**
98
+ * 初始化应用接口
99
+ * @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
100
+ * @param {ApplicationData['interfaces']} interfaces - 接口配置数组
101
+ * @returns {void}
102
+ */
54
103
  initInterfaces(interfaces) {
55
104
  interfaces.forEach(async (interfaceItem) => {
56
105
  let _interface = await this.loadInterface(interfaceItem);
@@ -65,11 +114,23 @@ var Application = class {
65
114
  }
66
115
  });
67
116
  }
117
+ /**
118
+ * 初始化应用功能函数
119
+ * @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
120
+ * @param {ApplicationData['functions']} functions - 功能配置数组,可选
121
+ * @returns {void}
122
+ */
68
123
  initFunctions(functions) {
69
124
  (functions || []).forEach(async (functionItem) => {
70
125
  this.setFunction(functionItem.function_code, functionItem);
71
126
  });
72
127
  }
128
+ /**
129
+ * 加载接口组件
130
+ * @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
131
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
132
+ * @returns {Promise<ApplicationInterface>} 加载后的接口配置
133
+ */
73
134
  async loadInterface(interfaceItem) {
74
135
  if (interfaceItem.Component) {
75
136
  return interfaceItem;
@@ -80,24 +141,71 @@ var Application = class {
80
141
  }
81
142
  return interfaceItem;
82
143
  }
144
+ /**
145
+ * 设置页面
146
+ * @description 将页面接口添加到接口映射表中
147
+ * @param {string} code - 页面编码
148
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
149
+ * @returns {void}
150
+ */
83
151
  setInterface(code, interfaceItem) {
84
152
  this.interfaces.set(code, interfaceItem);
85
153
  }
154
+ /**
155
+ * 设置组件
156
+ * @description 将组件添加到组件映射表中
157
+ * @param {string} code - 组件编码
158
+ * @param {ApplicationInterface} component - 组件配置项
159
+ * @returns {void}
160
+ */
86
161
  setComponent(code, component) {
87
162
  this.components.set(code, component);
88
163
  }
164
+ /**
165
+ * 设置功能函数
166
+ * @description 将功能函数添加到功能映射表中
167
+ * @param {string} code - 功能编码
168
+ * @param {ApplicationInterface} functionItem - 功能配置项
169
+ * @returns {void}
170
+ */
89
171
  setFunction(code, functionItem) {
90
172
  this.functions.set(code, functionItem);
91
173
  }
174
+ /**
175
+ * 获取页面
176
+ * @description 根据编码从接口映射表中获取页面接口
177
+ * @param {string} code - 页面编码
178
+ * @returns {ApplicationInterface | undefined} 接口配置项或undefined
179
+ */
92
180
  getInterface(code) {
93
181
  return this.interfaces.get(code);
94
182
  }
183
+ /**
184
+ * 获取组件
185
+ * @description 根据编码从组件映射表中获取组件
186
+ * @param {string} code - 组件编码
187
+ * @returns {any | undefined} 组件或undefined
188
+ */
95
189
  getComponent(code) {
96
190
  return this.components.get(code);
97
191
  }
192
+ /**
193
+ * 获取功能函数
194
+ * @description 根据编码从功能映射表中获取功能函数
195
+ * @param {string} code - 功能编码
196
+ * @returns {any | undefined} 功能函数或undefined
197
+ */
98
198
  getFunction(code) {
99
199
  return this.functions.get(code);
100
200
  }
201
+ /**
202
+ * 执行功能函数
203
+ * @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
204
+ * @param {string} code - 功能编码
205
+ * @param {any} params - 传递给功能函数的参数对象,可选
206
+ * @param {...any} args - 传递给功能函数的其他参数
207
+ * @returns {any} 功能函数的执行结果
208
+ */
101
209
  runFunction(code, params, ...args) {
102
210
  var _a;
103
211
  const _params = {
@@ -106,6 +214,31 @@ var Application = class {
106
214
  };
107
215
  return (_a = this.getFunction(code)) == null ? void 0 : _a.code(_params, ...args);
108
216
  }
217
+ /**
218
+ * 应用添加后触发的钩子函数
219
+ * @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
220
+ * @param {Application} application - 被添加的应用实例
221
+ * @returns {Promise<void>}
222
+ * @author zhiwei.Wang
223
+ */
224
+ async afterAdd(application) {
225
+ }
226
+ /**
227
+ * 应用加载前触发的钩子函数
228
+ * @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
229
+ * @returns {Promise<void>}
230
+ * @author zhiwei.Wang
231
+ */
232
+ async beforeLoad(application) {
233
+ }
234
+ /**
235
+ * 应用加载完成后触发的钩子函数
236
+ * @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
237
+ * @returns {Promise<void>}
238
+ * @author zhiwei.Wang
239
+ */
240
+ async load(application) {
241
+ }
109
242
  };
110
243
  // Annotate the CommonJS export names for ESM import in node:
111
244
  0 && (module.exports = {
@@ -1,5 +1,5 @@
1
- import APP from "../app";
2
- import { Application, ApplicationData } from "./application";
1
+ import APP from '../app';
2
+ import { Application, ApplicationData } from './application';
3
3
  export declare class ApplicationManager {
4
4
  applicationList: Application[];
5
5
  protected app: APP;
@@ -7,7 +7,12 @@ export declare class ApplicationManager {
7
7
  constructor(applicationList: Application[], app: APP);
8
8
  init(applicationList: Application[] | ApplicationData[]): Promise<unknown>;
9
9
  add(application: Application): Promise<void>;
10
- get(appName: Application["name"]): Application | undefined;
11
- remove(appName: Application["name"]): void;
10
+ get(appName: Application['name']): Application | undefined;
11
+ remove(appName: Application['name']): void;
12
12
  load(): Promise<void>;
13
+ /**
14
+ * 循环所有的应用, 找出所有的components进行渲染
15
+ * @returns
16
+ */
17
+ getAllComponents(): any[];
13
18
  }
@@ -52,7 +52,7 @@ var ApplicationManager = class {
52
52
  }
53
53
  async add(application) {
54
54
  this.applications.set(application.name, application);
55
- await application.afterAdd(application);
55
+ await application._afterAdd(application);
56
56
  }
57
57
  get(appName) {
58
58
  let application = this.applications.get(appName);
@@ -62,13 +62,20 @@ var ApplicationManager = class {
62
62
  this.applications.delete(appName);
63
63
  }
64
64
  async load() {
65
- for (const plugin of this.applications.values()) {
66
- await plugin.beforeLoad();
65
+ for (const application of this.applications.values()) {
66
+ await application._beforeLoad();
67
67
  }
68
- for (const plugin of this.applications.values()) {
69
- await plugin.load();
68
+ for (const application of this.applications.values()) {
69
+ await application._load();
70
70
  }
71
71
  }
72
+ /**
73
+ * 循环所有的应用, 找出所有的components进行渲染
74
+ * @returns
75
+ */
76
+ getAllComponents() {
77
+ return Array.from(this.applications.values()).flatMap((application) => Array.from(application.components.values())).filter((component) => component.autoRender).map((component) => component.Component);
78
+ }
72
79
  };
73
80
  // Annotate the CommonJS export names for ESM import in node:
74
81
  0 && (module.exports = {
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/core",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",