@ibiz-template/core 0.0.4-beta.4 → 0.1.0

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.
Files changed (95) hide show
  1. package/dist/index.esm.js +429 -97
  2. package/dist/index.system.min.js +2 -1
  3. package/dist/index.system.min.js.map +1 -0
  4. package/out/constant/core/core.d.ts +2 -2
  5. package/out/constant/core/core.js +3 -4
  6. package/out/constant/util/util.d.ts.map +1 -1
  7. package/out/context/index.d.ts +17 -7
  8. package/out/context/index.d.ts.map +1 -1
  9. package/out/context/index.js +82 -40
  10. package/out/environment/environment.d.ts.map +1 -1
  11. package/out/environment/environment.js +5 -0
  12. package/out/error/model-error/model-error.d.ts +2 -2
  13. package/out/error/model-error/model-error.d.ts.map +1 -1
  14. package/out/error/model-error/model-error.js +0 -1
  15. package/out/error/runtime-model-error/runtime-model-error.d.ts +2 -2
  16. package/out/error/runtime-model-error/runtime-model-error.d.ts.map +1 -1
  17. package/out/error/runtime-model-error/runtime-model-error.js +0 -1
  18. package/out/ibizsys.d.ts +6 -4
  19. package/out/ibizsys.d.ts.map +1 -1
  20. package/out/ibizsys.js +6 -4
  21. package/out/index.d.ts +0 -1
  22. package/out/index.d.ts.map +1 -1
  23. package/out/index.js +0 -1
  24. package/out/install.d.ts.map +1 -1
  25. package/out/install.js +0 -2
  26. package/out/interface/i-environment/i-environment.d.ts +39 -0
  27. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  28. package/out/types.d.ts +11 -22
  29. package/out/types.d.ts.map +1 -1
  30. package/out/utils/download-file/download-file.d.ts.map +1 -1
  31. package/out/utils/index.d.ts +1 -1
  32. package/out/utils/index.d.ts.map +1 -1
  33. package/out/utils/index.js +1 -1
  34. package/out/utils/interceptor/core-interceptor.d.ts.map +1 -1
  35. package/out/utils/interceptor/core-interceptor.js +6 -2
  36. package/out/utils/interceptor/interceptor.d.ts +2 -2
  37. package/out/utils/interceptor/interceptor.d.ts.map +1 -1
  38. package/out/utils/logger/logger.d.ts +2 -2
  39. package/out/utils/logger/logger.d.ts.map +1 -1
  40. package/out/utils/logger/logger.js +5 -1
  41. package/out/utils/namespace/namespace.d.ts.map +1 -1
  42. package/out/utils/net/net.d.ts +12 -2
  43. package/out/utils/net/net.d.ts.map +1 -1
  44. package/out/utils/net/net.js +31 -5
  45. package/out/utils/recursive/find-recursive-child.d.ts +43 -0
  46. package/out/utils/recursive/find-recursive-child.d.ts.map +1 -0
  47. package/out/utils/recursive/find-recursive-child.js +90 -0
  48. package/out/utils/string-util/string-util.js +1 -2
  49. package/out/utils/style/remote-style.d.ts.map +1 -1
  50. package/out/utils/style/remote-style.js +1 -2
  51. package/out/utils/sync/count-latch.d.ts.map +1 -1
  52. package/out/utils/types/types.d.ts +10 -0
  53. package/out/utils/types/types.d.ts.map +1 -1
  54. package/out/utils/upload/select-file.d.ts.map +1 -1
  55. package/out/utils/upload/select-file.js +1 -1
  56. package/out/utils/upload/upload-file.d.ts.map +1 -1
  57. package/out/utils/upload/upload-file.js +2 -1
  58. package/out/utils/url-helper/url-helper.d.ts.map +1 -1
  59. package/out/utils/url-helper/url-helper.js +2 -1
  60. package/out/utils/util/util.d.ts +58 -0
  61. package/out/utils/util/util.d.ts.map +1 -1
  62. package/out/utils/util/util.js +123 -0
  63. package/package.json +9 -6
  64. package/src/constant/core/core.ts +2 -2
  65. package/src/constant/util/util.ts +1 -1
  66. package/src/context/index.ts +91 -47
  67. package/src/environment/environment.ts +5 -0
  68. package/src/error/model-error/model-error.ts +4 -2
  69. package/src/error/runtime-model-error/runtime-model-error.ts +4 -2
  70. package/src/ibizsys.ts +7 -4
  71. package/src/index.ts +0 -1
  72. package/src/install.ts +0 -2
  73. package/src/interface/i-environment/i-environment.ts +44 -0
  74. package/src/types.ts +12 -23
  75. package/src/utils/click-outside/click-outside.ts +6 -6
  76. package/src/utils/download-file/download-file.ts +2 -2
  77. package/src/utils/event/event.ts +1 -1
  78. package/src/utils/index.ts +1 -1
  79. package/src/utils/interceptor/core-interceptor.ts +7 -2
  80. package/src/utils/interceptor/interceptor.ts +3 -3
  81. package/src/utils/logger/logger.ts +8 -1
  82. package/src/utils/namespace/namespace.ts +4 -1
  83. package/src/utils/net/net.ts +35 -11
  84. package/src/utils/recursive/find-recursive-child.ts +133 -0
  85. package/src/utils/style/remote-style.ts +1 -3
  86. package/src/utils/sync/count-latch.ts +5 -5
  87. package/src/utils/types/types.ts +13 -0
  88. package/src/utils/upload/select-file.ts +2 -2
  89. package/src/utils/upload/upload-file.ts +6 -5
  90. package/src/utils/url-helper/url-helper.ts +6 -5
  91. package/src/utils/util/util.ts +144 -2
  92. package/out/factory-center.d.ts +0 -11
  93. package/out/factory-center.d.ts.map +0 -1
  94. package/out/factory-center.js +0 -10
  95. package/src/factory-center.ts +0 -9
package/dist/index.esm.js CHANGED
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  // ../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js
28
28
  var require_loglevel = __commonJS({
29
29
  "../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js"(exports, module) {
30
+ "use strict";
30
31
  (function(root, definition) {
31
32
  "use strict";
32
33
  if (typeof define === "function" && define.amd) {
@@ -228,15 +229,15 @@ var require_loglevel = __commonJS({
228
229
  if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
229
230
  throw new TypeError("You must supply a name when creating a logger.");
230
231
  }
231
- var logger = _loggersByName[name];
232
- if (!logger) {
233
- logger = _loggersByName[name] = new Logger2(
232
+ var logger2 = _loggersByName[name];
233
+ if (!logger2) {
234
+ logger2 = _loggersByName[name] = new Logger2(
234
235
  name,
235
236
  defaultLogger.getLevel(),
236
237
  defaultLogger.methodFactory
237
238
  );
238
239
  }
239
- return logger;
240
+ return logger2;
240
241
  };
241
242
  var _log = typeof window !== undefinedType ? window.log : void 0;
242
243
  defaultLogger.noConflict = function() {
@@ -254,17 +255,145 @@ var require_loglevel = __commonJS({
254
255
  }
255
256
  });
256
257
 
258
+ // ../../node_modules/.pnpm/loglevel-plugin-prefix@0.8.4/node_modules/loglevel-plugin-prefix/lib/loglevel-plugin-prefix.js
259
+ var require_loglevel_plugin_prefix = __commonJS({
260
+ "../../node_modules/.pnpm/loglevel-plugin-prefix@0.8.4/node_modules/loglevel-plugin-prefix/lib/loglevel-plugin-prefix.js"(exports, module) {
261
+ "use strict";
262
+ (function(root, factory) {
263
+ if (typeof define === "function" && define.amd) {
264
+ define(factory);
265
+ } else if (typeof module === "object" && module.exports) {
266
+ module.exports = factory();
267
+ } else {
268
+ root.prefix = factory(root);
269
+ }
270
+ })(exports, function(root) {
271
+ "use strict";
272
+ var merge4 = function(target) {
273
+ var i = 1;
274
+ var length = arguments.length;
275
+ var key;
276
+ for (; i < length; i++) {
277
+ for (key in arguments[i]) {
278
+ if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
279
+ target[key] = arguments[i][key];
280
+ }
281
+ }
282
+ }
283
+ return target;
284
+ };
285
+ var defaults = {
286
+ template: "[%t] %l:",
287
+ levelFormatter: function(level) {
288
+ return level.toUpperCase();
289
+ },
290
+ nameFormatter: function(name) {
291
+ return name || "root";
292
+ },
293
+ timestampFormatter: function(date) {
294
+ return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
295
+ },
296
+ format: void 0
297
+ };
298
+ var loglevel;
299
+ var configs = {};
300
+ var reg2 = function(rootLogger) {
301
+ if (!rootLogger || !rootLogger.getLogger) {
302
+ throw new TypeError("Argument is not a root logger");
303
+ }
304
+ loglevel = rootLogger;
305
+ };
306
+ var apply2 = function(logger2, config) {
307
+ if (!logger2 || !logger2.setLevel) {
308
+ throw new TypeError("Argument is not a logger");
309
+ }
310
+ var originalFactory = logger2.methodFactory;
311
+ var name = logger2.name || "";
312
+ var parent = configs[name] || configs[""] || defaults;
313
+ function methodFactory(methodName, logLevel, loggerName) {
314
+ var originalMethod = originalFactory(methodName, logLevel, loggerName);
315
+ var options = configs[loggerName] || configs[""];
316
+ var hasTimestamp = options.template.indexOf("%t") !== -1;
317
+ var hasLevel = options.template.indexOf("%l") !== -1;
318
+ var hasName = options.template.indexOf("%n") !== -1;
319
+ return function() {
320
+ var content = "";
321
+ var length = arguments.length;
322
+ var args = Array(length);
323
+ var key = 0;
324
+ for (; key < length; key++) {
325
+ args[key] = arguments[key];
326
+ }
327
+ if (name || !configs[loggerName]) {
328
+ var timestamp = options.timestampFormatter(/* @__PURE__ */ new Date());
329
+ var level = options.levelFormatter(methodName);
330
+ var lname = options.nameFormatter(loggerName);
331
+ if (options.format) {
332
+ content += options.format(level, lname, timestamp);
333
+ } else {
334
+ content += options.template;
335
+ if (hasTimestamp) {
336
+ content = content.replace(/%t/, timestamp);
337
+ }
338
+ if (hasLevel)
339
+ content = content.replace(/%l/, level);
340
+ if (hasName)
341
+ content = content.replace(/%n/, lname);
342
+ }
343
+ if (args.length && typeof args[0] === "string") {
344
+ args[0] = content + " " + args[0];
345
+ } else {
346
+ args.unshift(content);
347
+ }
348
+ }
349
+ originalMethod.apply(void 0, args);
350
+ };
351
+ }
352
+ if (!configs[name]) {
353
+ logger2.methodFactory = methodFactory;
354
+ }
355
+ config = config || {};
356
+ if (config.template)
357
+ config.format = void 0;
358
+ configs[name] = merge4({}, parent, config);
359
+ logger2.setLevel(logger2.getLevel());
360
+ if (!loglevel) {
361
+ logger2.warn(
362
+ "It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"
363
+ );
364
+ }
365
+ return logger2;
366
+ };
367
+ var api = {
368
+ reg: reg2,
369
+ apply: apply2
370
+ };
371
+ var save;
372
+ if (root) {
373
+ save = root.prefix;
374
+ api.noConflict = function() {
375
+ if (root.prefix === api) {
376
+ root.prefix = save;
377
+ }
378
+ return api;
379
+ };
380
+ }
381
+ return api;
382
+ });
383
+ }
384
+ });
385
+
257
386
  // src/command/utils/linked-list.ts
258
- var _Node = class {
387
+ var _Node = class _Node {
259
388
  constructor(element) {
260
389
  this.element = element;
261
390
  this.next = _Node.Undefined;
262
391
  this.prev = _Node.Undefined;
263
392
  }
264
393
  };
265
- var Node = _Node;
266
394
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
- Node.Undefined = new _Node(void 0);
395
+ _Node.Undefined = new _Node(void 0);
396
+ var Node = _Node;
268
397
  var LinkedList = class {
269
398
  constructor() {
270
399
  this._first = Node.Undefined;
@@ -440,11 +569,11 @@ var CommandsRegistry = class {
440
569
  */
441
570
  registerCommand(idOrCommand, handler, opts) {
442
571
  if (!idOrCommand) {
443
- throw new Error(`invalid command`);
572
+ throw new Error("invalid command");
444
573
  }
445
574
  if (typeof idOrCommand === "string") {
446
575
  if (!handler) {
447
- throw new Error(`invalid command`);
576
+ throw new Error("invalid command");
448
577
  }
449
578
  return this.registerCommand({ id: idOrCommand, handler, opts });
450
579
  }
@@ -555,7 +684,7 @@ var CommandController = class {
555
684
  if (command) {
556
685
  return command.handler(...args);
557
686
  }
558
- throw new Error(`\u672A\u6CE8\u518C\u6307\u4EE4: ${id}\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4`);
687
+ throw new Error("\u672A\u6CE8\u518C\u6307\u4EE4: ".concat(id, "\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4"));
559
688
  }
560
689
  /**
561
690
  * 判断指令是否存在,可直接抛出异常
@@ -569,7 +698,7 @@ var CommandController = class {
569
698
  hasCommand(id, err) {
570
699
  const bol = !!this.commandRegister.hasCommand(id);
571
700
  if (err === true && bol === true) {
572
- throw new Error(`\u672A\u6CE8\u518C\u6307\u4EE4: ${id}\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4`);
701
+ throw new Error("\u672A\u6CE8\u518C\u6307\u4EE4: ".concat(id, "\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4"));
573
702
  }
574
703
  return bol;
575
704
  }
@@ -603,7 +732,7 @@ CoreConst.DEFAULT_MODEL_SERVICE_TAG = "default";
603
732
  * @date 2022-07-20 15:07:28
604
733
  * @static
605
734
  */
606
- CoreConst.TOKEN = "access_token";
735
+ CoreConst.TOKEN = "ibzuaa-token";
607
736
  /**
608
737
  * 访问令牌标识过期时间
609
738
  *
@@ -612,7 +741,7 @@ CoreConst.TOKEN = "access_token";
612
741
  * @static
613
742
  * @memberof CoreConst
614
743
  */
615
- CoreConst.TOKEN_EXPIRES = "access_token_expires";
744
+ CoreConst.TOKEN_EXPIRES = "ibzuaa-token_expires";
616
745
 
617
746
  // src/constant/util/util.ts
618
747
  var NOOP = () => {
@@ -655,13 +784,13 @@ var MenuPermissionMode = /* @__PURE__ */ ((MenuPermissionMode2) => {
655
784
 
656
785
  // src/context/index.ts
657
786
  import { clone } from "ramda";
658
- var IBizContext = class {
787
+ var IBizContext = class _IBizContext {
659
788
  /**
660
789
  * Creates an instance of IBizContext.
661
790
  *
662
791
  * @author chitanda
663
792
  * @date 2022-07-14 10:07:15
664
- * @param {IDatum} [context={}] 自身的上下文
793
+ * @param {IData} [context={}] 自身的上下文
665
794
  * @param {IContext} [parent]
666
795
  */
667
796
  // eslint-disable-next-line default-param-last
@@ -671,47 +800,53 @@ var IBizContext = class {
671
800
  value: []
672
801
  });
673
802
  if (parent) {
674
- const self = this;
675
- Object.defineProperty(this, "_parent", {
676
- enumerable: false,
677
- writable: true,
678
- value: parent
679
- });
680
- Object.defineProperty(this, "_context", {
681
- enumerable: false,
682
- writable: true,
683
- value: {}
684
- });
685
- const properties = {};
686
- const keys = Object.keys(parent);
687
- keys.forEach((key) => {
688
- properties[key] = {
689
- enumerable: true,
690
- set(val) {
691
- if (val == null) {
692
- self._context[key] = null;
693
- } else {
694
- self._context[key] = val;
695
- }
696
- },
697
- get() {
698
- if (self._context[key] !== void 0) {
699
- return self._context[key];
700
- }
701
- return parent[key];
702
- }
703
- };
704
- });
705
- Object.defineProperties(this, properties);
803
+ this.initWithParent(parent);
706
804
  }
707
805
  Object.assign(this, context);
708
806
  }
807
+ initWithParent(parent) {
808
+ const self = this;
809
+ Object.defineProperty(this, "_parent", {
810
+ enumerable: false,
811
+ writable: true,
812
+ value: parent
813
+ });
814
+ Object.defineProperty(this, "_context", {
815
+ enumerable: false,
816
+ writable: true,
817
+ value: {}
818
+ });
819
+ const properties = {};
820
+ const keys = Object.keys(parent);
821
+ keys.forEach((key) => {
822
+ if (Object.prototype.hasOwnProperty.call(this, key)) {
823
+ return;
824
+ }
825
+ properties[key] = {
826
+ enumerable: true,
827
+ set(val) {
828
+ if (val == null) {
829
+ self._context[key] = null;
830
+ } else {
831
+ self._context[key] = val;
832
+ }
833
+ },
834
+ get() {
835
+ if (self._context[key] !== void 0) {
836
+ return self._context[key];
837
+ }
838
+ return self._parent[key];
839
+ }
840
+ };
841
+ });
842
+ Object.defineProperties(this, properties);
843
+ }
709
844
  /**
710
845
  * 返回自身的上下文,独有的和与父有差异的。
711
846
  *
712
847
  * @author lxm
713
848
  * @date 2022-12-08 17:12:26
714
- * @returns {*} {IDatum}
849
+ * @returns {*} {IData}
715
850
  */
716
851
  getOwnContext() {
717
852
  const result = {};
@@ -743,25 +878,53 @@ var IBizContext = class {
743
878
  * @return {*} {IBizContext}
744
879
  */
745
880
  clone() {
746
- const newContext = new IBizContext(
881
+ const newContext = new _IBizContext(
747
882
  clone(this.getOwnContext()),
748
883
  this._parent
749
884
  );
750
885
  this._associationContext.push(newContext);
751
886
  return newContext;
752
887
  }
888
+ /**
889
+ * 在不改变对象引用的情况下,重置上下文
890
+ * 等效于重新实例化,但是引用不变
891
+ * @author lxm
892
+ * @date 2023-05-24 10:30:40
893
+ * @param {IData} [context={}]
894
+ * @param {IContext} [parent]
895
+ */
896
+ // eslint-disable-next-line default-param-last
897
+ reset(context = {}, parent) {
898
+ this._associationContext.forEach((item) => {
899
+ item.destroy();
900
+ });
901
+ if (this._parent) {
902
+ this._parent = {};
903
+ this._context = {};
904
+ }
905
+ Object.keys(this).forEach((key) => {
906
+ try {
907
+ delete this[key];
908
+ } catch (error) {
909
+ }
910
+ });
911
+ if (parent) {
912
+ this.initWithParent(parent);
913
+ }
914
+ Object.assign(this, context);
915
+ }
753
916
  /**
754
917
  * 上下文只有在视图初始化时,调用 create 方法
755
918
  *
756
919
  * @author chitanda
757
920
  * @date 2023-03-13 16:03:32
758
921
  * @static
759
- * @param {IDatum} [context]
922
+ * @param {IData} [context]
760
923
  * @param {IContext} [parent]
761
924
  * @return {*} {IContext}
762
925
  */
763
926
  static create(context, parent) {
764
- return new IBizContext(context, parent);
927
+ return new _IBizContext(context, parent);
765
928
  }
766
929
  };
767
930
 
@@ -773,6 +936,7 @@ var Environment = {
773
936
  baseUrl: "/api",
774
937
  appId: "",
775
938
  pluginBaseUrl: "./plugins",
939
+ isLocalModel: false,
776
940
  remoteModelUrl: "/remotemodel",
777
941
  assetsUrl: "./assets",
778
942
  dcSystem: "",
@@ -783,7 +947,11 @@ var Environment = {
783
947
  menuPermissionMode: "MIXIN" /* MIXIN */,
784
948
  enablePermission: true,
785
949
  routePlaceholder: "-",
786
- enableWfAllHistory: false
950
+ enableWfAllHistory: false,
951
+ isMob: false,
952
+ isSaaSMode: true,
953
+ AppTitle: "\u5E94\u7528",
954
+ favicon: "./favicon.ico"
787
955
  };
788
956
 
789
957
  // src/error/http-error/http-error.ts
@@ -820,9 +988,8 @@ var ModelError = class extends Error {
820
988
  * @param {IModelObject} model 模板未支持的模型
821
989
  * @param {string} [msg]
822
990
  */
823
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
824
991
  constructor(model, msg) {
825
- super(`\u300C${model.id}\u300D\u6A21\u578B${msg ? `\uFF1A ${msg}` : ""}`);
992
+ super("\u300C".concat(model.id, "\u300D\u6A21\u578B").concat(msg ? "\uFF1A ".concat(msg) : ""));
826
993
  this.model = model;
827
994
  this.name = "\u672A\u652F\u6301\u7684\u6A21\u578B";
828
995
  }
@@ -847,9 +1014,8 @@ var RuntimeModelError = class extends Error {
847
1014
  * @param {IModelObject} model 丢失配置的模型
848
1015
  * @param {string} [msg] 缺失配置描述
849
1016
  */
850
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
851
1017
  constructor(model, msg) {
852
- super(`\u300C${model.id}\u300D\u6A21\u578B${msg ? `\uFF1A ${msg}` : ""}`);
1018
+ super("\u300C".concat(model.id, "\u300D\u6A21\u578B").concat(msg ? "\uFF1A ".concat(msg) : ""));
853
1019
  this.model = model;
854
1020
  this.name = "\u6A21\u578B\u914D\u7F6E\u7F3A\u5931";
855
1021
  }
@@ -858,6 +1024,7 @@ var RuntimeModelError = class extends Error {
858
1024
  // src/utils/util/util.ts
859
1025
  import { debounce as debounce2 } from "lodash-es";
860
1026
  import { getCookie } from "qx-util";
1027
+ import { isNotNil, isNil } from "ramda";
861
1028
  function getToken() {
862
1029
  return getCookie(CoreConst.TOKEN);
863
1030
  }
@@ -865,6 +1032,14 @@ function isOverlap(arr1, arr2) {
865
1032
  const newArr = Array.from(/* @__PURE__ */ new Set([...arr1, ...arr2]));
866
1033
  return newArr.length !== arr1.length + arr2.length;
867
1034
  }
1035
+ function isElementSame(arr1, arr2, field) {
1036
+ if (arr1.length !== arr2.length) {
1037
+ return false;
1038
+ }
1039
+ const allElements = field ? [...arr1.map((item) => item[field]), ...arr2.map((item) => item[field])] : [...arr1, ...arr2];
1040
+ const newArr = Array.from(new Set(allElements));
1041
+ return newArr.length === arr1.length;
1042
+ }
868
1043
  function debounceAndMerge(func, mergeFunc, wait) {
869
1044
  let oldParams;
870
1045
  const debounceFunc = debounce2((...params) => {
@@ -912,6 +1087,68 @@ function debounceAndAsyncMerge(func, mergeFunc, wait) {
912
1087
  };
913
1088
  return fun;
914
1089
  }
1090
+ function mergeInLeft(l, r2) {
1091
+ Object.keys(r2).forEach((key) => {
1092
+ if (isNotNil(r2[key])) {
1093
+ l[key] = r2[key];
1094
+ }
1095
+ });
1096
+ }
1097
+ function mergeDefaultInLeft(l, r2) {
1098
+ Object.keys(r2).forEach((key) => {
1099
+ if (isNotNil(r2[key]) && isNil(l[key])) {
1100
+ l[key] = r2[key];
1101
+ }
1102
+ });
1103
+ }
1104
+ function compareArr(arr1, arr2, keyField) {
1105
+ const all = /* @__PURE__ */ new Set([...arr1, ...arr2]);
1106
+ const more = [];
1107
+ const less = [];
1108
+ const same = [];
1109
+ if (keyField) {
1110
+ const arr1Keys = arr1.map((item) => item[keyField]);
1111
+ const arr2Keys = arr2.map((item) => item[keyField]);
1112
+ all.forEach((item) => {
1113
+ if (!arr1Keys.includes(item[keyField])) {
1114
+ less.push(item);
1115
+ return;
1116
+ }
1117
+ if (!arr2Keys.includes(item[keyField])) {
1118
+ more.push(item);
1119
+ return;
1120
+ }
1121
+ same.push(item);
1122
+ });
1123
+ } else {
1124
+ all.forEach((item) => {
1125
+ if (!arr1.includes(item)) {
1126
+ less.push(item);
1127
+ return;
1128
+ }
1129
+ if (!arr2.includes(item)) {
1130
+ more.push(item);
1131
+ return;
1132
+ }
1133
+ same.push(item);
1134
+ });
1135
+ }
1136
+ return {
1137
+ more,
1138
+ less,
1139
+ same
1140
+ };
1141
+ }
1142
+ function toNumberOrNil(value) {
1143
+ if (isNil(value)) {
1144
+ return void 0;
1145
+ }
1146
+ const num = Number(value);
1147
+ if (Number.isNaN(num)) {
1148
+ return void 0;
1149
+ }
1150
+ return num;
1151
+ }
915
1152
 
916
1153
  // src/utils/interceptor/interceptor.ts
917
1154
  var Interceptor = class {
@@ -998,38 +1235,37 @@ var Interceptor = class {
998
1235
  // src/utils/interceptor/core-interceptor.ts
999
1236
  var CoreInterceptor = class extends Interceptor {
1000
1237
  async onBeforeRequest(config) {
1001
- await super.onBeforeRequest(config);
1238
+ config = await super.onBeforeRequest(config);
1002
1239
  const { headers } = config;
1003
- headers.set("Authorization", `Bearer ${getToken()}`);
1240
+ headers.set("Authorization", "Bearer ".concat(getToken()));
1241
+ let systemId = ibiz.env.dcSystem;
1004
1242
  const { orgData } = ibiz;
1005
1243
  if (orgData) {
1006
1244
  if (orgData.systemid) {
1007
- headers.set("srfsystemid", orgData.systemid);
1245
+ systemId = orgData.systemid;
1008
1246
  }
1009
1247
  if (orgData.orgid) {
1010
1248
  headers.set("srforgid", orgData.orgid);
1011
1249
  }
1012
1250
  }
1251
+ headers.set("srfsystemid", systemId);
1013
1252
  return config;
1014
1253
  }
1015
1254
  };
1016
1255
 
1017
- // src/utils/logger/logger.ts
1018
- var Logger = __toESM(require_loglevel(), 1);
1019
-
1020
1256
  // src/utils/namespace/namespace.ts
1021
1257
  var defaultNamespace = "ibiz";
1022
1258
  var statePrefix = "is-";
1023
1259
  function _bem(namespace, block, blockSuffix, element, modifier) {
1024
- let cls = `${namespace}-${block}`;
1260
+ let cls = "".concat(namespace, "-").concat(block);
1025
1261
  if (blockSuffix) {
1026
- cls += `-${blockSuffix}`;
1262
+ cls += "-".concat(blockSuffix);
1027
1263
  }
1028
1264
  if (element) {
1029
- cls += `__${element}`;
1265
+ cls += "__".concat(element);
1030
1266
  }
1031
1267
  if (modifier) {
1032
- cls += `--${modifier}`;
1268
+ cls += "--".concat(modifier);
1033
1269
  }
1034
1270
  return cls;
1035
1271
  }
@@ -1142,7 +1378,7 @@ var Namespace = class {
1142
1378
  * @return {*} {string}
1143
1379
  */
1144
1380
  is(name, state) {
1145
- return name && state ? `${statePrefix}${name}` : "";
1381
+ return name && state ? "".concat(statePrefix).concat(name) : "";
1146
1382
  }
1147
1383
  /**
1148
1384
  * 生成使用到的 css 变量 style 对象
@@ -1187,7 +1423,7 @@ var Namespace = class {
1187
1423
  * @return {*} {string}
1188
1424
  */
1189
1425
  cssVarName(name) {
1190
- return `--${this.namespace}-${name}`;
1426
+ return "--".concat(this.namespace, "-").concat(name);
1191
1427
  }
1192
1428
  /**
1193
1429
  * 生成块 css var 变量名称
@@ -1198,7 +1434,7 @@ var Namespace = class {
1198
1434
  * @return {*} {string}
1199
1435
  */
1200
1436
  cssVarBlockName(name) {
1201
- return `--${this.namespace}-${this.block}-${name}`;
1437
+ return "--".concat(this.namespace, "-").concat(this.block, "-").concat(name);
1202
1438
  }
1203
1439
  };
1204
1440
 
@@ -1259,6 +1495,16 @@ var Net = class {
1259
1495
  * @protected
1260
1496
  */
1261
1497
  this.urlReg = /^http[s]?:\/\/[^\s]*/;
1498
+ /**
1499
+ * 请求等待队列,防止重复请求。当有完全相同请求参数的请求时,会等待上一个请求完成后把结果返回给当前请求,不会重复请求
1500
+ * key: 由请求的 config 生成的字符串,用于唯一标识请求
1501
+ * value: 当前正在请求的 Promise
1502
+ *
1503
+ * @author chitanda
1504
+ * @date 2023-06-07 14:06:19
1505
+ * @protected
1506
+ */
1507
+ this.waitRequest = /* @__PURE__ */ new Map();
1262
1508
  /**
1263
1509
  * 注册的拦截器
1264
1510
  *
@@ -1308,7 +1554,7 @@ var Net = class {
1308
1554
  get presetConfig() {
1309
1555
  return {
1310
1556
  // 请求前缀路径
1311
- baseURL: this.instance.defaults.baseURL || `${ibiz.env.baseUrl}/${ibiz.env.appId}`,
1557
+ baseURL: this.instance.defaults.baseURL || "".concat(ibiz.env.baseUrl, "/").concat(ibiz.env.appId),
1312
1558
  headers: {
1313
1559
  "Content-Type": "application/json;charset=UTF-8",
1314
1560
  Accept: "application/json"
@@ -1454,12 +1700,25 @@ var Net = class {
1454
1700
  * @returns {*} {Promise<IHttpResponse>}
1455
1701
  */
1456
1702
  async request(url, config = {}) {
1703
+ const cfg = this.mergeConfig({ url }, config);
1704
+ const key = JSON.stringify(cfg);
1457
1705
  try {
1458
- const response = await this.instance.request(
1459
- this.mergeConfig({ url }, config)
1460
- );
1706
+ let requestPromise = null;
1707
+ if (!this.waitRequest.has(key)) {
1708
+ requestPromise = this.instance.request(cfg);
1709
+ this.waitRequest.set(key, requestPromise);
1710
+ } else {
1711
+ requestPromise = this.waitRequest.get(key);
1712
+ }
1713
+ const response = await requestPromise;
1714
+ if (this.waitRequest.has(key)) {
1715
+ this.waitRequest.delete(key);
1716
+ }
1461
1717
  return this.doResponseResult(response);
1462
1718
  } catch (error) {
1719
+ if (this.waitRequest.has(key)) {
1720
+ this.waitRequest.delete(key);
1721
+ }
1463
1722
  throw new HttpError(error);
1464
1723
  }
1465
1724
  }
@@ -1527,13 +1786,13 @@ var Net = class {
1527
1786
  const strParams = stringify(params);
1528
1787
  if (notNilEmpty(strParams)) {
1529
1788
  if (url.endsWith("?")) {
1530
- url = `${url}${strParams}`;
1789
+ url = "".concat(url).concat(strParams);
1531
1790
  } else if (url.indexOf("?") !== -1 && url.endsWith("&")) {
1532
- url = `${url}${strParams}`;
1791
+ url = "".concat(url).concat(strParams);
1533
1792
  } else if (url.indexOf("?") !== -1 && !url.endsWith("&")) {
1534
- url = `${url}&${strParams}`;
1793
+ url = "".concat(url, "&").concat(strParams);
1535
1794
  } else {
1536
- url = `${url}?${strParams}`;
1795
+ url = "".concat(url, "?").concat(strParams);
1537
1796
  }
1538
1797
  }
1539
1798
  return url;
@@ -1560,14 +1819,14 @@ var StringUtil = class {
1560
1819
  const strArr = str.match(this.contextReg);
1561
1820
  strArr == null ? void 0 : strArr.forEach((_key) => {
1562
1821
  const key = _key.slice(10, _key.length - 1);
1563
- str = str.replace(`\${context.${key}}`, context[key] || "");
1822
+ str = str.replace("${context.".concat(key, "}"), context[key] || "");
1564
1823
  });
1565
1824
  }
1566
1825
  if (notNilEmpty2(data)) {
1567
1826
  const strArr = str.match(this.dataReg);
1568
1827
  strArr == null ? void 0 : strArr.forEach((_key) => {
1569
1828
  const key = _key.slice(7, _key.length - 1);
1570
- str = str.replace(`\${data.${key}}`, data[key] || "");
1829
+ str = str.replace("${data.".concat(key, "}"), data[key] || "");
1571
1830
  });
1572
1831
  }
1573
1832
  }
@@ -1603,7 +1862,8 @@ var UrlHelper = class {
1603
1862
  * @returns {*}
1604
1863
  */
1605
1864
  static get routeBase() {
1606
- return `${this.appBase}/#`;
1865
+ const hashIndex = window.location.href.lastIndexOf("#/");
1866
+ return window.location.href.slice(0, hashIndex + 1);
1607
1867
  }
1608
1868
  /**
1609
1869
  * 应用的的基础路径
@@ -1616,7 +1876,7 @@ var UrlHelper = class {
1616
1876
  */
1617
1877
  static get appBase() {
1618
1878
  const { origin, pathname } = window.location;
1619
- return `${origin}${pathname}`.replace(/\/$/, "");
1879
+ return "".concat(origin).concat(pathname).replace(/\/$/, "");
1620
1880
  }
1621
1881
  /**
1622
1882
  * #开始到末尾,即路由地址
@@ -1775,9 +2035,9 @@ function colorBlend(color1, color2, p = 0.5, format = "hex") {
1775
2035
  result[2].toString(16),
1776
2036
  result[3] === 0 ? "00" : r(result[3] * 255).toString(16)
1777
2037
  ];
1778
- return `#${hex[0]}${hex[1]}${hex[2]}${hex[3]}`;
2038
+ return "#".concat(hex[0]).concat(hex[1]).concat(hex[2]).concat(hex[3]);
1779
2039
  }
1780
- return `rgb(${result[0]} ${result[1]} ${result[2]} / ${result[3]})`;
2040
+ return "rgb(".concat(result[0], " ").concat(result[1], " ").concat(result[2], " / ").concat(result[3], ")");
1781
2041
  }
1782
2042
 
1783
2043
  // src/utils/download-file/download-file.ts
@@ -1872,7 +2132,7 @@ function selectFile(_opts) {
1872
2132
  );
1873
2133
  const input = document.createElement("input");
1874
2134
  input.setAttribute("type", "file");
1875
- input.setAttribute("multiple", `${opts.multiple}`);
2135
+ input.setAttribute("multiple", "".concat(opts.multiple));
1876
2136
  input.setAttribute("accept", opts.accept);
1877
2137
  input.onchange = (e) => {
1878
2138
  const inputEl = e.target;
@@ -1922,7 +2182,7 @@ function uploadFile(_opts) {
1922
2182
  files.forEach((file) => {
1923
2183
  data.append("file", file);
1924
2184
  });
1925
- throw new Error(`\u591A\u5E94\u7528\u6A21\u5F0F\u7B49\u5F85\u91CD\u65B0\u5B9E\u73B0\u8BF7\u6C42`);
2185
+ throw new RuntimeError("\u591A\u5E94\u7528\u6A21\u5F0F\u7B49\u5F85\u91CD\u65B0\u5B9E\u73B0\u8BF7\u6C42");
1926
2186
  };
1927
2187
  const executeSingleUpload = async (files) => {
1928
2188
  const resultFiles = files.map((file) => {
@@ -1961,7 +2221,7 @@ function uploadFile(_opts) {
1961
2221
  file.error = error;
1962
2222
  });
1963
2223
  ibiz.log.error(error);
1964
- ibiz.log.error(`${files.map((file) => file.name).join(",")}\u4E0A\u4F20\u5931\u8D25`);
2224
+ ibiz.log.error("".concat(files.map((file) => file.name).join(","), "\u4E0A\u4F20\u5931\u8D25"));
1965
2225
  }
1966
2226
  return resultFiles;
1967
2227
  };
@@ -2095,9 +2355,80 @@ async function setRemoteStyle(url) {
2095
2355
  styleDom.innerText = res.data;
2096
2356
  document.head.appendChild(styleDom);
2097
2357
  } catch (error) {
2098
- Logger.debug("\u52A0\u8F7D\u8FDC\u7A0B\u6837\u5F0F\u8868\u5931\u8D25", url);
2358
+ ibiz.log.debug("\u52A0\u8F7D\u8FDC\u7A0B\u6837\u5F0F\u8868\u5931\u8D25", url);
2359
+ }
2360
+ }
2361
+
2362
+ // src/utils/recursive/find-recursive-child.ts
2363
+ import { mergeDeepRight } from "ramda";
2364
+ var IterateOpts = {
2365
+ /** 子集合属性数组 */
2366
+ childrenFields: ["children"]
2367
+ };
2368
+ var BreakError = new Error("\u4E2D\u65AD\u64CD\u4F5C");
2369
+ function getChildField(parent, fields) {
2370
+ var _a;
2371
+ for (const field of fields) {
2372
+ if ((_a = parent[field]) == null ? void 0 : _a.length) {
2373
+ return parent[field];
2374
+ }
2375
+ }
2376
+ }
2377
+ function _recursiveIterate(parent, callback, opts) {
2378
+ const { childrenFields } = mergeDeepRight(IterateOpts, opts || {});
2379
+ const children = getChildField(parent, childrenFields);
2380
+ if (children == null ? void 0 : children.length) {
2381
+ for (const child of children) {
2382
+ const isBreak = callback(child);
2383
+ if (isBreak) {
2384
+ throw BreakError;
2385
+ }
2386
+ recursiveIterate(child, callback, opts);
2387
+ }
2388
+ }
2389
+ }
2390
+ function recursiveIterate(parent, callback, opts) {
2391
+ try {
2392
+ _recursiveIterate(parent, callback, opts);
2393
+ } catch (error) {
2394
+ if (error !== BreakError) {
2395
+ throw error;
2396
+ }
2099
2397
  }
2100
2398
  }
2399
+ var CompareOpts = {
2400
+ ...IterateOpts,
2401
+ /** 比较的属性 */
2402
+ compareField: "name"
2403
+ };
2404
+ function findRecursiveChild(parent, key, opts) {
2405
+ const { compareField, compareCallback } = mergeDeepRight(
2406
+ CompareOpts,
2407
+ opts || {}
2408
+ );
2409
+ const _compareCallback = compareCallback || ((child) => {
2410
+ return child[compareField] === key;
2411
+ });
2412
+ let find;
2413
+ recursiveIterate(
2414
+ parent,
2415
+ (item) => {
2416
+ if (_compareCallback(item, key, compareField)) {
2417
+ find = item;
2418
+ return true;
2419
+ }
2420
+ },
2421
+ opts
2422
+ );
2423
+ return find;
2424
+ }
2425
+
2426
+ // src/utils/logger/logger.ts
2427
+ var Logger = __toESM(require_loglevel(), 1);
2428
+ var prefix = __toESM(require_loglevel_plugin_prefix(), 1);
2429
+ var logger = Logger.noConflict();
2430
+ prefix.reg(logger);
2431
+ prefix.apply(logger);
2101
2432
 
2102
2433
  // src/ibizsys.ts
2103
2434
  var IBizSys = class {
@@ -2110,12 +2441,13 @@ var IBizSys = class {
2110
2441
  */
2111
2442
  this.env = Environment;
2112
2443
  /**
2113
- * 日志对象
2444
+ * 日志输出工具类
2114
2445
  *
2115
2446
  * @author chitanda
2116
- * @date 2022-10-25 20:10:22
2447
+ * @date 2023-07-10 18:07:05
2448
+ * @type {Logger}
2117
2449
  */
2118
- this.log = Logger;
2450
+ this.log = logger;
2119
2451
  /**
2120
2452
  * 网络请求工具类(发送默认请求)
2121
2453
  *
@@ -2135,17 +2467,12 @@ var IBizSys = class {
2135
2467
  }
2136
2468
  };
2137
2469
 
2138
- // src/factory-center.ts
2139
- var FactoryCenter = class {
2140
- };
2141
-
2142
2470
  // src/install.ts
2143
2471
  function install() {
2144
2472
  if (window.ibiz) {
2145
2473
  throw new Error("ibiz \u5DF2\u7ECF\u5B58\u5728, \u65E0\u9700\u91CD\u590D\u5B89\u88C5");
2146
2474
  }
2147
2475
  window.ibiz = new IBizSys();
2148
- window.___fc = new FactoryCenter();
2149
2476
  }
2150
2477
  export {
2151
2478
  CommandController,
@@ -2154,7 +2481,6 @@ export {
2154
2481
  CoreInterceptor,
2155
2482
  CountLatch,
2156
2483
  Environment,
2157
- FactoryCenter,
2158
2484
  HttpError,
2159
2485
  HttpResponse,
2160
2486
  HttpStatusMessageConst,
@@ -2162,7 +2488,6 @@ export {
2162
2488
  IBizSys,
2163
2489
  Interceptor,
2164
2490
  LinkedList,
2165
- Logger,
2166
2491
  LoginMode,
2167
2492
  MenuPermissionMode,
2168
2493
  ModelError,
@@ -2177,22 +2502,29 @@ export {
2177
2502
  calcMimeByFileName,
2178
2503
  colorBlend,
2179
2504
  commands,
2505
+ compareArr,
2180
2506
  debounce,
2181
2507
  debounceAndAsyncMerge,
2182
2508
  debounceAndMerge,
2183
2509
  downloadFileFromBlob,
2184
2510
  eventPath,
2185
2511
  fileListToArr,
2512
+ findRecursiveChild,
2186
2513
  getToken,
2187
2514
  install,
2515
+ isElementSame,
2188
2516
  isEventInside,
2189
2517
  isImage,
2190
2518
  isOverlap,
2191
2519
  listenJSEvent,
2520
+ mergeDefaultInLeft,
2521
+ mergeInLeft,
2192
2522
  onClickOutside,
2523
+ recursiveIterate,
2193
2524
  selectFile,
2194
2525
  setRemoteStyle,
2195
2526
  throttle,
2196
2527
  toDisposable,
2528
+ toNumberOrNil,
2197
2529
  uploadFile
2198
2530
  };