@ibiz-template/core 0.7.41-alpha.12 → 0.7.41-alpha.138
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.
- package/dist/index.esm.js +94 -23
- package/dist/index.system.min.js +1 -1
- package/out/environment/environment.d.ts.map +1 -1
- package/out/environment/environment.js +10 -0
- package/out/error/http-error/http-error-factory.d.ts +1 -1
- package/out/error/http-error/http-error-factory.d.ts.map +1 -1
- package/out/error/http-error/http-error-factory.js +11 -1
- package/out/error/http-error/http-error.d.ts +2 -2
- package/out/error/http-error/http-error.d.ts.map +1 -1
- package/out/interface/api/chat-message/i-api-chat-message.d.ts +63 -0
- package/out/interface/api/chat-message/i-api-chat-message.d.ts.map +1 -0
- package/out/interface/api/chat-message/i-api-chat-message.js +1 -0
- package/out/interface/api/chat-message/index.d.ts +2 -0
- package/out/interface/api/chat-message/index.d.ts.map +1 -0
- package/out/interface/api/chat-message/index.js +1 -0
- package/out/interface/api/environment/i-devtool-config.d.ts +29 -1
- package/out/interface/api/environment/i-devtool-config.d.ts.map +1 -1
- package/out/interface/api/environment/i-environment.d.ts +146 -1
- package/out/interface/api/environment/i-environment.d.ts.map +1 -1
- package/out/interface/api/ibizsys/i-app-data.d.ts +57 -0
- package/out/interface/api/ibizsys/i-app-data.d.ts.map +1 -0
- package/out/interface/api/ibizsys/i-app-data.js +1 -0
- package/out/interface/api/ibizsys/i-org-data.d.ts +1 -1
- package/out/interface/api/ibizsys/index.d.ts +1 -0
- package/out/interface/api/ibizsys/index.d.ts.map +1 -1
- package/out/interface/api/index.d.ts +1 -0
- package/out/interface/api/index.d.ts.map +1 -1
- package/out/interface/api/index.js +1 -0
- package/out/interface/api/utils/i-api-i18n.d.ts +9 -9
- package/out/interface/api/utils/index.d.ts +1 -0
- package/out/interface/api/utils/index.d.ts.map +1 -1
- package/out/interface/api/utils/message-center/base/i-message-base.d.ts +3 -3
- package/out/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/async-action/i-command-async-action.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/i-message-command.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/internal-message/i-command-internal-message.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.d.ts +1 -1
- package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts +5 -0
- package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts.map +1 -1
- package/out/interface/api/utils/message-center/common/i-portal-message.d.ts +3 -3
- package/out/interface/api/utils/message-center/console/i-message-console.d.ts +1 -1
- package/out/interface/api/utils/message-center/error/i-message-error.d.ts +1 -1
- package/out/interface/api/utils/message-center/i-message-center.d.ts +2 -2
- package/out/interface/api/utils/net/i-api-http-error.d.ts +39 -0
- package/out/interface/api/utils/net/i-api-http-error.d.ts.map +1 -0
- package/out/interface/api/utils/net/i-api-http-error.js +1 -0
- package/out/interface/api/utils/net/i-api-net.d.ts +1 -1
- package/out/interface/i-chat-message/i-chat-message.d.ts +2 -49
- package/out/interface/i-chat-message/i-chat-message.d.ts.map +1 -1
- package/out/utils/download-file/download-file.d.ts.map +1 -1
- package/out/utils/download-file/download-file.js +5 -1
- package/out/utils/interceptor/core-interceptor.js +2 -1
- package/out/utils/net/http-response.d.ts +2 -1
- package/out/utils/net/http-response.d.ts.map +1 -1
- package/out/utils/net/http-response.js +5 -1
- package/out/utils/net/net.d.ts +1 -1
- package/out/utils/net/net.d.ts.map +1 -1
- package/out/utils/net/net.js +16 -6
- package/out/utils/recursive/find-recursive-child.d.ts +20 -0
- package/out/utils/recursive/find-recursive-child.d.ts.map +1 -1
- package/out/utils/recursive/find-recursive-child.js +69 -7
- package/out/utils/string-util/string-util.d.ts.map +1 -1
- package/out/utils/string-util/string-util.js +2 -4
- package/package.json +5 -4
- package/src/command/command-register.ts +121 -0
- package/src/command/command.ts +78 -0
- package/src/command/index.ts +8 -0
- package/src/command/utils/index.ts +2 -0
- package/src/command/utils/linked-list.ts +136 -0
- package/src/command/utils/util.ts +103 -0
- package/src/constant/core/core.ts +54 -0
- package/src/constant/emoji/emoji.ts +2929 -0
- package/src/constant/http-status-message/http-status-message.ts +18 -0
- package/src/constant/index.ts +4 -0
- package/src/constant/util/util.ts +3 -0
- package/src/context/index.ts +231 -0
- package/src/environment/environment.ts +67 -0
- package/src/error/http-error/entity-error.ts +29 -0
- package/src/error/http-error/http-error-factory.ts +33 -0
- package/src/error/http-error/http-error.ts +52 -0
- package/src/error/index.ts +7 -0
- package/src/error/model-error/model-error.ts +27 -0
- package/src/error/notice-error/notice-error.ts +16 -0
- package/src/error/runtime-error/runtime-error.ts +13 -0
- package/src/error/runtime-model-error/runtime-model-error.ts +27 -0
- package/src/ibizsys.ts +82 -0
- package/src/index.ts +14 -0
- package/src/install.ts +12 -0
- package/src/interface/api/chat-message/i-api-chat-message.ts +71 -0
- package/src/interface/api/chat-message/index.ts +1 -0
- package/src/interface/api/constant/index.ts +2 -0
- package/src/interface/api/constant/login-mode/login-mode.ts +25 -0
- package/src/interface/api/constant/menu-permission-mode/menu-permission-mode.ts +20 -0
- package/src/interface/api/environment/i-devtool-config.ts +76 -0
- package/src/interface/api/environment/i-environment.ts +532 -0
- package/src/interface/api/environment/index.ts +2 -0
- package/src/interface/api/global-param/i-api-context.ts +37 -0
- package/src/interface/api/global-param/i-global-param.ts +27 -0
- package/src/interface/api/global-param/index.ts +2 -0
- package/src/interface/api/ibizsys/i-api-ibizsys.ts +54 -0
- package/src/interface/api/ibizsys/i-app-data.ts +64 -0
- package/src/interface/api/ibizsys/i-org-data.ts +31 -0
- package/src/interface/api/ibizsys/index.ts +3 -0
- package/src/interface/api/index.ts +6 -0
- package/src/interface/api/utils/i-api-i18n.ts +56 -0
- package/src/interface/api/utils/index.ts +5 -0
- package/src/interface/api/utils/message-center/base/i-message-all.ts +8 -0
- package/src/interface/api/utils/message-center/base/i-message-base.ts +29 -0
- package/src/interface/api/utils/message-center/base/index.ts +2 -0
- package/src/interface/api/utils/message-center/command/add-in-changed/i-add-in-changed.ts +25 -0
- package/src/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.ts +16 -0
- package/src/interface/api/utils/message-center/command/async-action/i-command-async-action.ts +17 -0
- package/src/interface/api/utils/message-center/command/change/i-command-change.ts +8 -0
- package/src/interface/api/utils/message-center/command/create/i-command-create.ts +18 -0
- package/src/interface/api/utils/message-center/command/i-command-base.ts +23 -0
- package/src/interface/api/utils/message-center/command/i-message-command.ts +94 -0
- package/src/interface/api/utils/message-center/command/index.ts +20 -0
- package/src/interface/api/utils/message-center/command/internal-message/i-command-internal-message.ts +17 -0
- package/src/interface/api/utils/message-center/command/internal-message/i-internal-message.ts +132 -0
- package/src/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.ts +17 -0
- package/src/interface/api/utils/message-center/command/mark-open-data/i-mark-open-data.ts +47 -0
- package/src/interface/api/utils/message-center/command/remove/i-command-remove.ts +18 -0
- package/src/interface/api/utils/message-center/command/update/i-command-update.ts +18 -0
- package/src/interface/api/utils/message-center/common/i-app-data-entity.ts +16 -0
- package/src/interface/api/utils/message-center/common/i-message-center-event.ts +15 -0
- package/src/interface/api/utils/message-center/common/i-msg-meta-data.ts +13 -0
- package/src/interface/api/utils/message-center/common/i-portal-async-action.ts +144 -0
- package/src/interface/api/utils/message-center/common/i-portal-message.ts +84 -0
- package/src/interface/api/utils/message-center/common/index.ts +5 -0
- package/src/interface/api/utils/message-center/console/i-message-console.ts +17 -0
- package/src/interface/api/utils/message-center/error/i-message-error.ts +17 -0
- package/src/interface/api/utils/message-center/i-message-center.ts +53 -0
- package/src/interface/api/utils/message-center/index.ts +6 -0
- package/src/interface/api/utils/net/i-api-http-error.ts +43 -0
- package/src/interface/api/utils/net/i-api-net.ts +93 -0
- package/src/interface/api/utils/net/i-http-response.ts +67 -0
- package/src/interface/click-outside/click-outside.ts +51 -0
- package/src/interface/command/command/i-command-option.ts +47 -0
- package/src/interface/command/command/i-command.ts +68 -0
- package/src/interface/command/disposable/i-disposable.ts +12 -0
- package/src/interface/command/i-command-controller.ts +50 -0
- package/src/interface/command/index.ts +11 -0
- package/src/interface/context/index.ts +42 -0
- package/src/interface/error/index.ts +13 -0
- package/src/interface/i-chat-message/i-chat-message.ts +16 -0
- package/src/interface/ibizsys/i-ibizsys.ts +33 -0
- package/src/interface/ibizsys/index.ts +1 -0
- package/src/interface/index.ts +11 -0
- package/src/interface/utils/i-18n.ts +22 -0
- package/src/interface/utils/index.ts +1 -0
- package/src/locale/en/index.ts +30 -0
- package/src/locale/index.ts +2 -0
- package/src/locale/zh-CN/index.ts +28 -0
- package/src/params/params.ts +131 -0
- package/src/types.ts +26 -0
- package/src/utils/bit-mask/bit-mask.ts +87 -0
- package/src/utils/click-outside/click-outside.ts +108 -0
- package/src/utils/clone/clone.ts +38 -0
- package/src/utils/color/color.ts +84 -0
- package/src/utils/cookie-util/cookie-util.ts +192 -0
- package/src/utils/data-type/data-types.ts +93 -0
- package/src/utils/download-file/download-file.ts +110 -0
- package/src/utils/event/event.ts +69 -0
- package/src/utils/history-list/history-item.ts +41 -0
- package/src/utils/history-list/history-list.ts +137 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/interceptor/core-interceptor.ts +127 -0
- package/src/utils/interceptor/index.ts +2 -0
- package/src/utils/interceptor/interceptor.ts +122 -0
- package/src/utils/logger/logger.ts +34 -0
- package/src/utils/message-center/base/message-all.ts +10 -0
- package/src/utils/message-center/base/message-base.ts +73 -0
- package/src/utils/message-center/command/add-in-changed/command-add-in-changed.ts +23 -0
- package/src/utils/message-center/command/async-action/command-async-action.ts +23 -0
- package/src/utils/message-center/command/change/command-change.ts +11 -0
- package/src/utils/message-center/command/command-base/command-base.ts +35 -0
- package/src/utils/message-center/command/create/command-create.ts +25 -0
- package/src/utils/message-center/command/internal-message/command-internal-message.ts +26 -0
- package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +23 -0
- package/src/utils/message-center/command/message-command.ts +162 -0
- package/src/utils/message-center/command/remove/command-remove.ts +25 -0
- package/src/utils/message-center/command/update/command-update.ts +25 -0
- package/src/utils/message-center/console/message-console.ts +27 -0
- package/src/utils/message-center/error/message-error.ts +27 -0
- package/src/utils/message-center/index.ts +1 -0
- package/src/utils/message-center/message-center.ts +77 -0
- package/src/utils/namespace/namespace.ts +217 -0
- package/src/utils/net/http-response.ts +60 -0
- package/src/utils/net/net.ts +463 -0
- package/src/utils/recursive/find-recursive-child.ts +238 -0
- package/src/utils/string-util/string-util.ts +76 -0
- package/src/utils/style/remote-style.ts +17 -0
- package/src/utils/sync/await-timeout.ts +29 -0
- package/src/utils/sync/count-latch.ts +79 -0
- package/src/utils/sync/index.ts +2 -0
- package/src/utils/types/types.ts +24 -0
- package/src/utils/upload/select-file.ts +93 -0
- package/src/utils/upload/upload-file.ts +194 -0
- package/src/utils/url-helper/url-helper.ts +52 -0
- package/src/utils/util/util.ts +580 -0
package/out/utils/net/net.js
CHANGED
|
@@ -121,7 +121,7 @@ export class Net {
|
|
|
121
121
|
return this.doResponseResult(response);
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
|
-
throw HttpErrorFactory.getInstance(error);
|
|
124
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
@@ -140,7 +140,7 @@ export class Net {
|
|
|
140
140
|
return this.doResponseResult(response);
|
|
141
141
|
}
|
|
142
142
|
catch (error) {
|
|
143
|
-
throw HttpErrorFactory.getInstance(error);
|
|
143
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
@@ -158,7 +158,7 @@ export class Net {
|
|
|
158
158
|
return this.doResponseResult(response);
|
|
159
159
|
}
|
|
160
160
|
catch (error) {
|
|
161
|
-
throw HttpErrorFactory.getInstance(error);
|
|
161
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
@@ -181,7 +181,7 @@ export class Net {
|
|
|
181
181
|
return this.doResponseResult(response);
|
|
182
182
|
}
|
|
183
183
|
catch (error) {
|
|
184
|
-
throw HttpErrorFactory.getInstance(error);
|
|
184
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
@@ -199,7 +199,7 @@ export class Net {
|
|
|
199
199
|
return this.doResponseResult(response);
|
|
200
200
|
}
|
|
201
201
|
catch (error) {
|
|
202
|
-
throw HttpErrorFactory.getInstance(error);
|
|
202
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
@@ -235,7 +235,7 @@ export class Net {
|
|
|
235
235
|
if (this.waitRequest.has(key)) {
|
|
236
236
|
this.waitRequest.delete(key);
|
|
237
237
|
}
|
|
238
|
-
throw HttpErrorFactory.getInstance(error);
|
|
238
|
+
throw await HttpErrorFactory.getInstance(error);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
/**
|
|
@@ -322,6 +322,16 @@ export class Net {
|
|
|
322
322
|
if (data && Object.prototype.hasOwnProperty.call(data, 'srfmenuitem')) {
|
|
323
323
|
delete data.srfmenuitem;
|
|
324
324
|
}
|
|
325
|
+
// [特殊参数识别]删除界面使用视图参数srfexportdataset
|
|
326
|
+
if (data &&
|
|
327
|
+
Object.prototype.hasOwnProperty.call(data, 'srfexportdataset')) {
|
|
328
|
+
delete data.srfexportdataset;
|
|
329
|
+
}
|
|
330
|
+
// [特殊参数识别]删除界面使用视图参数srfexportdatakey
|
|
331
|
+
if (data &&
|
|
332
|
+
Object.prototype.hasOwnProperty.call(data, 'srfexportdatakey')) {
|
|
333
|
+
delete data.srfexportdatakey;
|
|
334
|
+
}
|
|
325
335
|
// [特殊参数识别]删除界面使用视图参数srfdefdata
|
|
326
336
|
if (params && Object.prototype.hasOwnProperty.call(params, 'srfdefdata')) {
|
|
327
337
|
delete params.srfdefdata;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
declare const IterateOpts: {
|
|
3
3
|
/** 子集合属性数组 */
|
|
4
4
|
childrenFields: string[];
|
|
5
|
+
/** 是否跳出当前操作 */
|
|
6
|
+
isBreak: boolean;
|
|
5
7
|
};
|
|
6
8
|
/**
|
|
7
9
|
* @description 递归遍历子元素,递归遍历子元素 用法:传入数组和回调函数 无返回值
|
|
@@ -32,12 +34,30 @@ declare const IterateOpts: {
|
|
|
32
34
|
* @param {Partial<typeof IterateOpts>} [opts]
|
|
33
35
|
*/
|
|
34
36
|
export declare function recursiveIterate(parent: IData, callback: (item: any, _parent: any) => boolean | void, opts?: Partial<typeof IterateOpts>): void;
|
|
37
|
+
/**
|
|
38
|
+
* @description 递归执行,处理对象结构
|
|
39
|
+
* @export
|
|
40
|
+
* @param {IData} parent
|
|
41
|
+
* @param {((item: any, _parent?: any) => boolean | void)} callback
|
|
42
|
+
* @param {Partial<typeof IterateOpts>} [opts]
|
|
43
|
+
*/
|
|
44
|
+
export declare function _recursiveExecute(parent: IData, callback: (item: any, _parent?: any) => boolean | void, opts?: Partial<typeof IterateOpts>): void;
|
|
45
|
+
/**
|
|
46
|
+
* @description 递归执行,处理对象结构
|
|
47
|
+
* @export
|
|
48
|
+
* @param {IData} parent
|
|
49
|
+
* @param {((item: any, _parent: any) => boolean | void)} callback
|
|
50
|
+
* @param {Partial<typeof IterateOpts>} [opts]
|
|
51
|
+
*/
|
|
52
|
+
export declare function recursiveExecute(parent: IData, callback: (item: any, _parent: any) => boolean | void, opts?: Partial<typeof IterateOpts>): void;
|
|
35
53
|
/** 默认配置参数 */
|
|
36
54
|
declare const CompareOpts: {
|
|
37
55
|
/** 比较的属性 */
|
|
38
56
|
compareField: string;
|
|
39
57
|
/** 子集合属性数组 */
|
|
40
58
|
childrenFields: string[];
|
|
59
|
+
/** 是否跳出当前操作 */
|
|
60
|
+
isBreak: boolean;
|
|
41
61
|
};
|
|
42
62
|
type ICompareOpts = Partial<typeof CompareOpts> & {
|
|
43
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-recursive-child.d.ts","sourceRoot":"","sources":["../../../src/utils/recursive/find-recursive-child.ts"],"names":[],"mappings":"AAGA,aAAa;AACb,QAAA,MAAM,WAAW;IACf,cAAc;;
|
|
1
|
+
{"version":3,"file":"find-recursive-child.d.ts","sourceRoot":"","sources":["../../../src/utils/recursive/find-recursive-child.ts"],"names":[],"mappings":"AAGA,aAAa;AACb,QAAA,MAAM,WAAW;IACf,cAAc;;IAEd,eAAe;;CAEhB,CAAC;AA2DF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,GAAG,IAAI,EACrD,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,GACjC,IAAI,CAQN;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,GAAG,IAAI,EACtD,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,GACjC,IAAI,CAkBN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,GAAG,IAAI,EACrD,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,GACjC,IAAI,CAQN;AAED,aAAa;AACb,QAAA,MAAM,WAAW;IAEf,YAAY;;IAhKZ,cAAc;;IAEd,eAAe;;CAgKhB,CAAC;AAEF,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,GAAG;IAChD;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAChB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,KAAK,EACb,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,YAAY,GAClB,KAAK,GAAG,SAAS,CA0BnB"}
|
|
@@ -4,8 +4,10 @@ import { mergeDeepRight } from 'ramda';
|
|
|
4
4
|
const IterateOpts = {
|
|
5
5
|
/** 子集合属性数组 */
|
|
6
6
|
childrenFields: ['children'],
|
|
7
|
+
/** 是否跳出当前操作 */
|
|
8
|
+
isBreak: false,
|
|
7
9
|
};
|
|
8
|
-
const
|
|
10
|
+
const ReturnError = new Error('中断操作');
|
|
9
11
|
/**
|
|
10
12
|
* @description 获取子属性集合
|
|
11
13
|
* @param {IData} parent
|
|
@@ -20,16 +22,33 @@ function getChildField(parent, fields) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* @description 获取子属性对象
|
|
27
|
+
* @param {IData} parent
|
|
28
|
+
* @param {string[]} fields
|
|
29
|
+
* @returns {*} {(IData[] | undefined)}
|
|
30
|
+
*/
|
|
31
|
+
function getChildFieldObj(parent, fields) {
|
|
32
|
+
for (const field of fields) {
|
|
33
|
+
if (parent[field]) {
|
|
34
|
+
return parent[field];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
function _recursiveIterate(parent, callback, opts) {
|
|
24
39
|
const { childrenFields } = mergeDeepRight(IterateOpts, opts || {});
|
|
25
40
|
const children = getChildField(parent, childrenFields);
|
|
26
41
|
if (children === null || children === void 0 ? void 0 : children.length) {
|
|
27
|
-
for (
|
|
42
|
+
for (let i = 0; i < children.length; i++) {
|
|
43
|
+
const child = children[i];
|
|
28
44
|
// 递归自身的子成员
|
|
29
|
-
const
|
|
30
|
-
//
|
|
31
|
-
if (
|
|
32
|
-
|
|
45
|
+
const result = callback(child, parent);
|
|
46
|
+
// 回调返回true若未启用跳出当次操作则退出,启用跳出当次操作则跳出本次循环
|
|
47
|
+
if (result) {
|
|
48
|
+
if (opts === null || opts === void 0 ? void 0 : opts.isBreak) {
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
throw ReturnError;
|
|
33
52
|
}
|
|
34
53
|
// 递归孙的成员
|
|
35
54
|
recursiveIterate(child, callback, opts);
|
|
@@ -69,7 +88,50 @@ export function recursiveIterate(parent, callback, opts) {
|
|
|
69
88
|
_recursiveIterate(parent, callback, opts);
|
|
70
89
|
}
|
|
71
90
|
catch (error) {
|
|
72
|
-
if (error !==
|
|
91
|
+
if (error !== ReturnError) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @description 递归执行,处理对象结构
|
|
98
|
+
* @export
|
|
99
|
+
* @param {IData} parent
|
|
100
|
+
* @param {((item: any, _parent?: any) => boolean | void)} callback
|
|
101
|
+
* @param {Partial<typeof IterateOpts>} [opts]
|
|
102
|
+
*/
|
|
103
|
+
export function _recursiveExecute(parent, callback, opts) {
|
|
104
|
+
const { childrenFields } = mergeDeepRight(IterateOpts, opts || {});
|
|
105
|
+
const children = getChildFieldObj(parent, childrenFields);
|
|
106
|
+
if (children) {
|
|
107
|
+
for (let i = 0; i < Object.values(children).length; i++) {
|
|
108
|
+
const child = Object.values(children)[i];
|
|
109
|
+
const result = callback(child, parent);
|
|
110
|
+
// 回调返回true若未启用跳出当次操作则退出,启用跳出当次操作则跳出本次循环
|
|
111
|
+
if (result) {
|
|
112
|
+
if (opts === null || opts === void 0 ? void 0 : opts.isBreak) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
throw ReturnError;
|
|
116
|
+
}
|
|
117
|
+
// 递归孙的成员
|
|
118
|
+
_recursiveExecute(child, callback, opts);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @description 递归执行,处理对象结构
|
|
124
|
+
* @export
|
|
125
|
+
* @param {IData} parent
|
|
126
|
+
* @param {((item: any, _parent: any) => boolean | void)} callback
|
|
127
|
+
* @param {Partial<typeof IterateOpts>} [opts]
|
|
128
|
+
*/
|
|
129
|
+
export function recursiveExecute(parent, callback, opts) {
|
|
130
|
+
try {
|
|
131
|
+
_recursiveExecute(parent, callback, opts);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (error !== ReturnError) {
|
|
73
135
|
throw error;
|
|
74
136
|
}
|
|
75
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-util.d.ts","sourceRoot":"","sources":["../../../src/utils/string-util/string-util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,UAAU;IACrB;;;;OAIG;IACH,MAAM,CAAC,UAAU,SAAgD;IAEjE;;;;OAIG;IACH,MAAM,CAAC,OAAO,SAA6C;IAE3D;;;;OAIG;IACH,MAAM,CAAC,SAAS,SAA+C;IAE/D;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,CACT,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,KAAK,GACX,MAAM;
|
|
1
|
+
{"version":3,"file":"string-util.d.ts","sourceRoot":"","sources":["../../../src/utils/string-util/string-util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,UAAU;IACrB;;;;OAIG;IACH,MAAM,CAAC,UAAU,SAAgD;IAEjE;;;;OAIG;IACH,MAAM,CAAC,OAAO,SAA6C;IAE3D;;;;OAIG;IACH,MAAM,CAAC,SAAS,SAA+C;IAE/D;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,CACT,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,KAAK,GACX,MAAM;CA0BV"}
|
|
@@ -32,10 +32,8 @@ export class StringUtil {
|
|
|
32
32
|
if (notNilEmpty(params)) {
|
|
33
33
|
const strArr = str.match(this.paramsReg);
|
|
34
34
|
strArr === null || strArr === void 0 ? void 0 : strArr.forEach(_key => {
|
|
35
|
-
const key = _key.slice(
|
|
36
|
-
|
|
37
|
-
str = str.replace(`\${params.${key}}`, params[key]);
|
|
38
|
-
}
|
|
35
|
+
const key = _key.slice(9, _key.length - 1);
|
|
36
|
+
str = str.replace(`\${params.${key}}`, params[key] || '');
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
if (notNilEmpty(data)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.7.41-alpha.
|
|
3
|
+
"version": "0.7.41-alpha.138",
|
|
4
4
|
"description": "运行时核心库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"out",
|
|
12
|
+
"src",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"license": "MIT",
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
35
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.8.2",
|
|
36
37
|
"lodash-es": "^4.17.21",
|
|
37
38
|
"loglevel": "^1.8.1",
|
|
38
39
|
"loglevel-plugin-prefix": "^0.8.4",
|
|
@@ -44,11 +45,11 @@
|
|
|
44
45
|
"@types/qs": "^6.9.11"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"axios": "^1.
|
|
48
|
+
"axios": "^1.8.2",
|
|
48
49
|
"lodash-es": "^4.17.21",
|
|
49
50
|
"qs": "^6.11.0",
|
|
50
51
|
"qx-util": "^0.4.8",
|
|
51
52
|
"ramda": "^0.29.0"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "6889724e696f8f8ffb221ec57c1eb8154e1acbb3"
|
|
54
55
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ICommand,
|
|
3
|
+
ICommandHandler,
|
|
4
|
+
ICommandOption,
|
|
5
|
+
ICommandRegistry,
|
|
6
|
+
ICommandsMap,
|
|
7
|
+
IDisposable,
|
|
8
|
+
} from '../interface';
|
|
9
|
+
import { LinkedList, toDisposable } from './utils';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 指令注册中心
|
|
13
|
+
* @export
|
|
14
|
+
* @class CommandsRegistry
|
|
15
|
+
* @implements {ICommandRegistry}
|
|
16
|
+
*/
|
|
17
|
+
export class CommandsRegistry implements ICommandRegistry {
|
|
18
|
+
/**
|
|
19
|
+
* @description 已经注册的所有指令
|
|
20
|
+
* @private
|
|
21
|
+
* @memberof CommandsRegistry
|
|
22
|
+
*/
|
|
23
|
+
private readonly commands = new Map<string, LinkedList<ICommand>>();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @description 注册指令
|
|
27
|
+
* @param {(string | ICommand)} idOrCommand 指令id或者指令对象
|
|
28
|
+
* @param {ICommandHandler} [handler] 指令处理器
|
|
29
|
+
* @param {ICommandOption} [opts] 指令配置参数
|
|
30
|
+
* @returns {*} {IDisposable} 返回一个可销毁对象,用于取消注册该指令
|
|
31
|
+
* @memberof CommandsRegistry
|
|
32
|
+
*/
|
|
33
|
+
registerCommand(
|
|
34
|
+
idOrCommand: string | ICommand,
|
|
35
|
+
handler?: ICommandHandler,
|
|
36
|
+
opts?: ICommandOption,
|
|
37
|
+
): IDisposable {
|
|
38
|
+
if (!idOrCommand) {
|
|
39
|
+
throw new Error(`invalid command`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof idOrCommand === 'string') {
|
|
43
|
+
if (!handler) {
|
|
44
|
+
throw new Error(`invalid command`);
|
|
45
|
+
}
|
|
46
|
+
return this.registerCommand({ id: idOrCommand, handler, opts });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { id } = idOrCommand;
|
|
50
|
+
|
|
51
|
+
let commands = this.commands.get(id);
|
|
52
|
+
if (!commands) {
|
|
53
|
+
commands = new LinkedList<ICommand>();
|
|
54
|
+
this.commands.set(id, commands);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const removeFn = commands.unshift(idOrCommand);
|
|
58
|
+
|
|
59
|
+
const ret = toDisposable(() => {
|
|
60
|
+
removeFn();
|
|
61
|
+
const command = this.commands.get(id);
|
|
62
|
+
if (command?.isEmpty()) {
|
|
63
|
+
this.commands.delete(id);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return ret;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description 指令是否已经注册
|
|
72
|
+
* @param {string} id
|
|
73
|
+
* @returns {*} {boolean}
|
|
74
|
+
* @memberof CommandsRegistry
|
|
75
|
+
*/
|
|
76
|
+
hasCommand(id: string): boolean {
|
|
77
|
+
return this.commands.has(id);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @description 查找指令
|
|
82
|
+
* @param {string} id
|
|
83
|
+
* @returns {*} {(ICommand | undefined)}
|
|
84
|
+
* @memberof CommandsRegistry
|
|
85
|
+
*/
|
|
86
|
+
getCommand(id: string): ICommand | undefined {
|
|
87
|
+
const list = this.commands.get(id);
|
|
88
|
+
if (!list || list.isEmpty()) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return list[Symbol.iterator]().next().value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @description 获取所有指令
|
|
96
|
+
* @returns {*} {ICommandsMap}
|
|
97
|
+
* @memberof CommandsRegistry
|
|
98
|
+
*/
|
|
99
|
+
getCommands(): ICommandsMap {
|
|
100
|
+
const result = new Map<string, ICommand>();
|
|
101
|
+
const keys = this.commands.keys();
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
const command = this.getCommand(key);
|
|
104
|
+
if (command) {
|
|
105
|
+
result.set(key, command);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @description 获取指令配置参数
|
|
113
|
+
* @param {string} id
|
|
114
|
+
* @returns {*} {(ICommandOption | undefined)}
|
|
115
|
+
* @memberof CommandsRegistry
|
|
116
|
+
*/
|
|
117
|
+
getCommandOpt(id: string): ICommandOption | undefined {
|
|
118
|
+
const cmd = this.getCommand(id);
|
|
119
|
+
return cmd?.opts;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ICommandController,
|
|
3
|
+
ICommandHandler,
|
|
4
|
+
ICommandOption,
|
|
5
|
+
IDisposable,
|
|
6
|
+
} from '../interface/command';
|
|
7
|
+
import { CommandsRegistry } from './command-register';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @description 指令控制器
|
|
11
|
+
* @export
|
|
12
|
+
* @class CommandController
|
|
13
|
+
*/
|
|
14
|
+
export class CommandController implements ICommandController {
|
|
15
|
+
/**
|
|
16
|
+
* @description 指令注册器
|
|
17
|
+
* @private
|
|
18
|
+
* @memberof CommandController
|
|
19
|
+
*/
|
|
20
|
+
private commandRegister = new CommandsRegistry();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @description 注册指令
|
|
24
|
+
* @param {string} id 指令id
|
|
25
|
+
* @param {ICommandHandler} handler 指令处理回调
|
|
26
|
+
* @param {ICommandOption} [opts] 指令参数
|
|
27
|
+
* @returns {*} {IDisposable} 指令释放对象
|
|
28
|
+
* @memberof CommandController
|
|
29
|
+
*/
|
|
30
|
+
register(
|
|
31
|
+
id: string,
|
|
32
|
+
handler: ICommandHandler,
|
|
33
|
+
opts?: ICommandOption,
|
|
34
|
+
): IDisposable {
|
|
35
|
+
return this.commandRegister.registerCommand(id, handler, opts);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @description 执行指令
|
|
40
|
+
* @template T
|
|
41
|
+
* @param {string} id 指令id
|
|
42
|
+
* @param {...unknown[]} args 指令参数
|
|
43
|
+
* @returns {*} {Promise<T>} 指令返回值
|
|
44
|
+
* @memberof CommandController
|
|
45
|
+
*/
|
|
46
|
+
async execute<T = undefined>(id: string, ...args: unknown[]): Promise<T> {
|
|
47
|
+
const command = this.commandRegister.getCommand(id);
|
|
48
|
+
if (command) {
|
|
49
|
+
return command.handler(...args) as T | Promise<T>;
|
|
50
|
+
}
|
|
51
|
+
throw new Error(ibiz.i18n.t('core.command.unregisteredCommand', { id }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @description 判断指令是否存在,没有则直接抛出异常
|
|
56
|
+
* @param {string} id 指令id
|
|
57
|
+
* @param {boolean} [err] 是否抛出异常
|
|
58
|
+
* @returns {*} {boolean} 是否存在
|
|
59
|
+
* @memberof CommandController
|
|
60
|
+
*/
|
|
61
|
+
hasCommand(id: string, err?: boolean): boolean {
|
|
62
|
+
const bol = !!this.commandRegister.hasCommand(id);
|
|
63
|
+
if (err === true && bol === true) {
|
|
64
|
+
throw new Error(`未注册指令: ${id},请先注册指令`);
|
|
65
|
+
}
|
|
66
|
+
return bol;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @description 获取指令参数
|
|
71
|
+
* @param {string} id 指令id
|
|
72
|
+
* @returns {*} {(ICommandOption | undefined)} 指令参数
|
|
73
|
+
* @memberof CommandController
|
|
74
|
+
*/
|
|
75
|
+
getCommandOpts(id: string): ICommandOption | undefined {
|
|
76
|
+
return this.commandRegister.getCommandOpt(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommandController } from './command';
|
|
2
|
+
|
|
3
|
+
export * from '../interface/command';
|
|
4
|
+
export * from './utils';
|
|
5
|
+
export { CommandsRegistry } from './command-register';
|
|
6
|
+
export { CommandController } from './command';
|
|
7
|
+
// 命令控制器
|
|
8
|
+
export const commands = new CommandController();
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
/* eslint-disable no-underscore-dangle */
|
|
3
|
+
/* eslint-disable max-classes-per-file */
|
|
4
|
+
class Node<E> {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
static readonly Undefined = new Node<any>(undefined);
|
|
7
|
+
|
|
8
|
+
element: E;
|
|
9
|
+
|
|
10
|
+
next: Node<E>;
|
|
11
|
+
|
|
12
|
+
prev: Node<E>;
|
|
13
|
+
|
|
14
|
+
constructor(element: E) {
|
|
15
|
+
this.element = element;
|
|
16
|
+
this.next = Node.Undefined;
|
|
17
|
+
this.prev = Node.Undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class LinkedList<E> {
|
|
22
|
+
private _first: Node<E> = Node.Undefined;
|
|
23
|
+
|
|
24
|
+
private _last: Node<E> = Node.Undefined;
|
|
25
|
+
|
|
26
|
+
private _size: number = 0;
|
|
27
|
+
|
|
28
|
+
get size(): number {
|
|
29
|
+
return this._size;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
isEmpty(): boolean {
|
|
33
|
+
return this._first === Node.Undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
clear(): void {
|
|
37
|
+
let node = this._first;
|
|
38
|
+
while (node !== Node.Undefined) {
|
|
39
|
+
const { next } = node;
|
|
40
|
+
node.prev = Node.Undefined;
|
|
41
|
+
node.next = Node.Undefined;
|
|
42
|
+
node = next;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this._first = Node.Undefined;
|
|
46
|
+
this._last = Node.Undefined;
|
|
47
|
+
this._size = 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
unshift(element: E): () => void {
|
|
51
|
+
return this._insert(element, false);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
push(element: E): () => void {
|
|
55
|
+
return this._insert(element, true);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private _insert(element: E, atTheEnd: boolean): () => void {
|
|
59
|
+
const newNode = new Node(element);
|
|
60
|
+
if (this._first === Node.Undefined) {
|
|
61
|
+
this._first = newNode;
|
|
62
|
+
this._last = newNode;
|
|
63
|
+
} else if (atTheEnd) {
|
|
64
|
+
// push
|
|
65
|
+
const oldLast = this._last!;
|
|
66
|
+
this._last = newNode;
|
|
67
|
+
newNode.prev = oldLast;
|
|
68
|
+
oldLast.next = newNode;
|
|
69
|
+
} else {
|
|
70
|
+
// unshift
|
|
71
|
+
const oldFirst = this._first;
|
|
72
|
+
this._first = newNode;
|
|
73
|
+
newNode.next = oldFirst;
|
|
74
|
+
oldFirst.prev = newNode;
|
|
75
|
+
}
|
|
76
|
+
this._size += 1;
|
|
77
|
+
|
|
78
|
+
let didRemove = false;
|
|
79
|
+
return () => {
|
|
80
|
+
if (!didRemove) {
|
|
81
|
+
didRemove = true;
|
|
82
|
+
this._remove(newNode);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
shift(): E | undefined {
|
|
88
|
+
if (this._first === Node.Undefined) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const res = this._first.element;
|
|
92
|
+
this._remove(this._first);
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
pop(): E | undefined {
|
|
97
|
+
if (this._last === Node.Undefined) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const res = this._last.element;
|
|
101
|
+
this._remove(this._last);
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private _remove(node: Node<E>): void {
|
|
106
|
+
if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
|
|
107
|
+
// middle
|
|
108
|
+
const anchor = node.prev;
|
|
109
|
+
anchor.next = node.next;
|
|
110
|
+
node.next.prev = anchor;
|
|
111
|
+
} else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
|
|
112
|
+
// only node
|
|
113
|
+
this._first = Node.Undefined;
|
|
114
|
+
this._last = Node.Undefined;
|
|
115
|
+
} else if (node.next === Node.Undefined) {
|
|
116
|
+
// last
|
|
117
|
+
this._last = this._last!.prev!;
|
|
118
|
+
this._last.next = Node.Undefined;
|
|
119
|
+
} else if (node.prev === Node.Undefined) {
|
|
120
|
+
// first
|
|
121
|
+
this._first = this._first!.next!;
|
|
122
|
+
this._first.prev = Node.Undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// done
|
|
126
|
+
this._size -= 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
*[Symbol.iterator](): Iterator<E> {
|
|
130
|
+
let node = this._first;
|
|
131
|
+
while (node !== Node.Undefined) {
|
|
132
|
+
yield node.element;
|
|
133
|
+
node = node.next;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|