@ibiz-template/core 0.0.3-beta.5 → 0.0.4-beta.2

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 (38) hide show
  1. package/dist/index.esm.js +2207 -0
  2. package/dist/index.system.min.js +1 -0
  3. package/out/constant/core/core.js +2 -1
  4. package/out/context/index.d.ts.map +1 -1
  5. package/out/context/index.js +1 -1
  6. package/out/environment/environment.d.ts.map +1 -1
  7. package/out/environment/environment.js +1 -0
  8. package/out/error/index.d.ts +2 -0
  9. package/out/error/index.d.ts.map +1 -1
  10. package/out/error/index.js +2 -0
  11. package/out/error/model-error/model-error.d.ts +22 -0
  12. package/out/error/model-error/model-error.d.ts.map +1 -0
  13. package/out/error/model-error/model-error.js +24 -0
  14. package/out/error/runtime-model-error/runtime-model-error.d.ts +23 -0
  15. package/out/error/runtime-model-error/runtime-model-error.d.ts.map +1 -0
  16. package/out/error/runtime-model-error/runtime-model-error.js +25 -0
  17. package/out/interface/i-environment/i-environment.d.ts +7 -0
  18. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  19. package/out/types.d.ts +8 -0
  20. package/out/types.d.ts.map +1 -1
  21. package/out/utils/index.d.ts +1 -0
  22. package/out/utils/index.d.ts.map +1 -1
  23. package/out/utils/index.js +1 -0
  24. package/out/utils/string-util/string-util.js +2 -1
  25. package/out/utils/types/types.d.ts +11 -0
  26. package/out/utils/types/types.d.ts.map +1 -0
  27. package/out/utils/types/types.js +1 -0
  28. package/package.json +7 -6
  29. package/src/context/index.ts +4 -1
  30. package/src/environment/environment.ts +1 -0
  31. package/src/error/index.ts +2 -0
  32. package/src/error/model-error/model-error.ts +24 -0
  33. package/src/error/runtime-model-error/runtime-model-error.ts +25 -0
  34. package/src/interface/i-environment/i-environment.ts +8 -0
  35. package/src/types.ts +9 -0
  36. package/src/utils/index.ts +1 -0
  37. package/src/utils/types/types.ts +9 -0
  38. package/dist/system/index.system.js +0 -1
@@ -0,0 +1,2207 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js
28
+ var require_loglevel = __commonJS({
29
+ "../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js"(exports, module) {
30
+ (function(root, definition) {
31
+ "use strict";
32
+ if (typeof define === "function" && define.amd) {
33
+ define(definition);
34
+ } else if (typeof module === "object" && module.exports) {
35
+ module.exports = definition();
36
+ } else {
37
+ root.log = definition();
38
+ }
39
+ })(exports, function() {
40
+ "use strict";
41
+ var noop = function() {
42
+ };
43
+ var undefinedType = "undefined";
44
+ var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
45
+ var logMethods = [
46
+ "trace",
47
+ "debug",
48
+ "info",
49
+ "warn",
50
+ "error"
51
+ ];
52
+ function bindMethod(obj, methodName) {
53
+ var method = obj[methodName];
54
+ if (typeof method.bind === "function") {
55
+ return method.bind(obj);
56
+ } else {
57
+ try {
58
+ return Function.prototype.bind.call(method, obj);
59
+ } catch (e) {
60
+ return function() {
61
+ return Function.prototype.apply.apply(method, [obj, arguments]);
62
+ };
63
+ }
64
+ }
65
+ }
66
+ function traceForIE() {
67
+ if (console.log) {
68
+ if (console.log.apply) {
69
+ console.log.apply(console, arguments);
70
+ } else {
71
+ Function.prototype.apply.apply(console.log, [console, arguments]);
72
+ }
73
+ }
74
+ if (console.trace)
75
+ console.trace();
76
+ }
77
+ function realMethod(methodName) {
78
+ if (methodName === "debug") {
79
+ methodName = "log";
80
+ }
81
+ if (typeof console === undefinedType) {
82
+ return false;
83
+ } else if (methodName === "trace" && isIE) {
84
+ return traceForIE;
85
+ } else if (console[methodName] !== void 0) {
86
+ return bindMethod(console, methodName);
87
+ } else if (console.log !== void 0) {
88
+ return bindMethod(console, "log");
89
+ } else {
90
+ return noop;
91
+ }
92
+ }
93
+ function replaceLoggingMethods(level, loggerName) {
94
+ for (var i = 0; i < logMethods.length; i++) {
95
+ var methodName = logMethods[i];
96
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
97
+ }
98
+ this.log = this.debug;
99
+ }
100
+ function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
101
+ return function() {
102
+ if (typeof console !== undefinedType) {
103
+ replaceLoggingMethods.call(this, level, loggerName);
104
+ this[methodName].apply(this, arguments);
105
+ }
106
+ };
107
+ }
108
+ function defaultMethodFactory(methodName, level, loggerName) {
109
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
110
+ }
111
+ function Logger2(name, defaultLevel, factory) {
112
+ var self = this;
113
+ var currentLevel;
114
+ defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
115
+ var storageKey = "loglevel";
116
+ if (typeof name === "string") {
117
+ storageKey += ":" + name;
118
+ } else if (typeof name === "symbol") {
119
+ storageKey = void 0;
120
+ }
121
+ function persistLevelIfPossible(levelNum) {
122
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
123
+ if (typeof window === undefinedType || !storageKey)
124
+ return;
125
+ try {
126
+ window.localStorage[storageKey] = levelName;
127
+ return;
128
+ } catch (ignore) {
129
+ }
130
+ try {
131
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
132
+ } catch (ignore) {
133
+ }
134
+ }
135
+ function getPersistedLevel() {
136
+ var storedLevel;
137
+ if (typeof window === undefinedType || !storageKey)
138
+ return;
139
+ try {
140
+ storedLevel = window.localStorage[storageKey];
141
+ } catch (ignore) {
142
+ }
143
+ if (typeof storedLevel === undefinedType) {
144
+ try {
145
+ var cookie = window.document.cookie;
146
+ var location = cookie.indexOf(
147
+ encodeURIComponent(storageKey) + "="
148
+ );
149
+ if (location !== -1) {
150
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
151
+ }
152
+ } catch (ignore) {
153
+ }
154
+ }
155
+ if (self.levels[storedLevel] === void 0) {
156
+ storedLevel = void 0;
157
+ }
158
+ return storedLevel;
159
+ }
160
+ function clearPersistedLevel() {
161
+ if (typeof window === undefinedType || !storageKey)
162
+ return;
163
+ try {
164
+ window.localStorage.removeItem(storageKey);
165
+ return;
166
+ } catch (ignore) {
167
+ }
168
+ try {
169
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
170
+ } catch (ignore) {
171
+ }
172
+ }
173
+ self.name = name;
174
+ self.levels = {
175
+ "TRACE": 0,
176
+ "DEBUG": 1,
177
+ "INFO": 2,
178
+ "WARN": 3,
179
+ "ERROR": 4,
180
+ "SILENT": 5
181
+ };
182
+ self.methodFactory = factory || defaultMethodFactory;
183
+ self.getLevel = function() {
184
+ return currentLevel;
185
+ };
186
+ self.setLevel = function(level, persist) {
187
+ if (typeof level === "string" && self.levels[level.toUpperCase()] !== void 0) {
188
+ level = self.levels[level.toUpperCase()];
189
+ }
190
+ if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
191
+ currentLevel = level;
192
+ if (persist !== false) {
193
+ persistLevelIfPossible(level);
194
+ }
195
+ replaceLoggingMethods.call(self, level, name);
196
+ if (typeof console === undefinedType && level < self.levels.SILENT) {
197
+ return "No console available for logging";
198
+ }
199
+ } else {
200
+ throw "log.setLevel() called with invalid level: " + level;
201
+ }
202
+ };
203
+ self.setDefaultLevel = function(level) {
204
+ defaultLevel = level;
205
+ if (!getPersistedLevel()) {
206
+ self.setLevel(level, false);
207
+ }
208
+ };
209
+ self.resetLevel = function() {
210
+ self.setLevel(defaultLevel, false);
211
+ clearPersistedLevel();
212
+ };
213
+ self.enableAll = function(persist) {
214
+ self.setLevel(self.levels.TRACE, persist);
215
+ };
216
+ self.disableAll = function(persist) {
217
+ self.setLevel(self.levels.SILENT, persist);
218
+ };
219
+ var initialLevel = getPersistedLevel();
220
+ if (initialLevel == null) {
221
+ initialLevel = defaultLevel;
222
+ }
223
+ self.setLevel(initialLevel, false);
224
+ }
225
+ var defaultLogger = new Logger2();
226
+ var _loggersByName = {};
227
+ defaultLogger.getLogger = function getLogger(name) {
228
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
229
+ throw new TypeError("You must supply a name when creating a logger.");
230
+ }
231
+ var logger = _loggersByName[name];
232
+ if (!logger) {
233
+ logger = _loggersByName[name] = new Logger2(
234
+ name,
235
+ defaultLogger.getLevel(),
236
+ defaultLogger.methodFactory
237
+ );
238
+ }
239
+ return logger;
240
+ };
241
+ var _log = typeof window !== undefinedType ? window.log : void 0;
242
+ defaultLogger.noConflict = function() {
243
+ if (typeof window !== undefinedType && window.log === defaultLogger) {
244
+ window.log = _log;
245
+ }
246
+ return defaultLogger;
247
+ };
248
+ defaultLogger.getLoggers = function getLoggers() {
249
+ return _loggersByName;
250
+ };
251
+ defaultLogger["default"] = defaultLogger;
252
+ return defaultLogger;
253
+ });
254
+ }
255
+ });
256
+
257
+ // src/command/utils/linked-list.ts
258
+ var _Node = class {
259
+ constructor(element) {
260
+ this.element = element;
261
+ this.next = _Node.Undefined;
262
+ this.prev = _Node.Undefined;
263
+ }
264
+ };
265
+ var Node = _Node;
266
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
+ Node.Undefined = new _Node(void 0);
268
+ var LinkedList = class {
269
+ constructor() {
270
+ this._first = Node.Undefined;
271
+ this._last = Node.Undefined;
272
+ this._size = 0;
273
+ }
274
+ get size() {
275
+ return this._size;
276
+ }
277
+ isEmpty() {
278
+ return this._first === Node.Undefined;
279
+ }
280
+ clear() {
281
+ let node = this._first;
282
+ while (node !== Node.Undefined) {
283
+ const { next } = node;
284
+ node.prev = Node.Undefined;
285
+ node.next = Node.Undefined;
286
+ node = next;
287
+ }
288
+ this._first = Node.Undefined;
289
+ this._last = Node.Undefined;
290
+ this._size = 0;
291
+ }
292
+ unshift(element) {
293
+ return this._insert(element, false);
294
+ }
295
+ push(element) {
296
+ return this._insert(element, true);
297
+ }
298
+ _insert(element, atTheEnd) {
299
+ const newNode = new Node(element);
300
+ if (this._first === Node.Undefined) {
301
+ this._first = newNode;
302
+ this._last = newNode;
303
+ } else if (atTheEnd) {
304
+ const oldLast = this._last;
305
+ this._last = newNode;
306
+ newNode.prev = oldLast;
307
+ oldLast.next = newNode;
308
+ } else {
309
+ const oldFirst = this._first;
310
+ this._first = newNode;
311
+ newNode.next = oldFirst;
312
+ oldFirst.prev = newNode;
313
+ }
314
+ this._size += 1;
315
+ let didRemove = false;
316
+ return () => {
317
+ if (!didRemove) {
318
+ didRemove = true;
319
+ this._remove(newNode);
320
+ }
321
+ };
322
+ }
323
+ shift() {
324
+ if (this._first === Node.Undefined) {
325
+ return void 0;
326
+ }
327
+ const res = this._first.element;
328
+ this._remove(this._first);
329
+ return res;
330
+ }
331
+ pop() {
332
+ if (this._last === Node.Undefined) {
333
+ return void 0;
334
+ }
335
+ const res = this._last.element;
336
+ this._remove(this._last);
337
+ return res;
338
+ }
339
+ _remove(node) {
340
+ if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
341
+ const anchor = node.prev;
342
+ anchor.next = node.next;
343
+ node.next.prev = anchor;
344
+ } else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
345
+ this._first = Node.Undefined;
346
+ this._last = Node.Undefined;
347
+ } else if (node.next === Node.Undefined) {
348
+ this._last = this._last.prev;
349
+ this._last.next = Node.Undefined;
350
+ } else if (node.prev === Node.Undefined) {
351
+ this._first = this._first.next;
352
+ this._first.prev = Node.Undefined;
353
+ }
354
+ this._size -= 1;
355
+ }
356
+ *[Symbol.iterator]() {
357
+ let node = this._first;
358
+ while (node !== Node.Undefined) {
359
+ yield node.element;
360
+ node = node.next;
361
+ }
362
+ }
363
+ };
364
+
365
+ // src/command/utils/util.ts
366
+ function once(fn) {
367
+ const _this = this;
368
+ let didCall = false;
369
+ let result;
370
+ return function() {
371
+ if (didCall) {
372
+ return result;
373
+ }
374
+ didCall = true;
375
+ result = fn.apply(_this, arguments);
376
+ return result;
377
+ };
378
+ }
379
+ function toDisposable(fn) {
380
+ const self = {
381
+ dispose: once(() => {
382
+ fn();
383
+ })
384
+ };
385
+ return self;
386
+ }
387
+ function debounce(func, wait, immediate) {
388
+ let timer;
389
+ return function(...args) {
390
+ if (timer) {
391
+ clearTimeout(timer);
392
+ }
393
+ if (immediate) {
394
+ const callNow = !timer;
395
+ timer = setTimeout(() => {
396
+ timer = null;
397
+ }, wait);
398
+ if (callNow) {
399
+ func.apply(this, args);
400
+ }
401
+ } else {
402
+ timer = setTimeout(() => {
403
+ func.apply(this, args);
404
+ }, wait);
405
+ }
406
+ };
407
+ }
408
+ function throttle(fn, wait) {
409
+ let timer = null;
410
+ return function(...args) {
411
+ if (!timer) {
412
+ timer = setTimeout(() => {
413
+ fn.apply(this, args);
414
+ timer = null;
415
+ }, wait);
416
+ }
417
+ };
418
+ }
419
+
420
+ // src/command/command-register.ts
421
+ var CommandsRegistry = class {
422
+ constructor() {
423
+ /**
424
+ * 已经注册的所有指令
425
+ *
426
+ * @author chitanda
427
+ * @date 2022-07-21 15:07:47
428
+ * @private
429
+ */
430
+ this.commands = /* @__PURE__ */ new Map();
431
+ }
432
+ /**
433
+ * 注册指令
434
+ *
435
+ * @author chitanda
436
+ * @date 2022-06-27 13:06:31
437
+ * @param {(string | ICommand)} idOrCommand
438
+ * @param {ICommandHandler} [handler]
439
+ * @return {*} {IDisposable}
440
+ */
441
+ registerCommand(idOrCommand, handler, opts) {
442
+ if (!idOrCommand) {
443
+ throw new Error(`invalid command`);
444
+ }
445
+ if (typeof idOrCommand === "string") {
446
+ if (!handler) {
447
+ throw new Error(`invalid command`);
448
+ }
449
+ return this.registerCommand({ id: idOrCommand, handler, opts });
450
+ }
451
+ const { id } = idOrCommand;
452
+ let commands2 = this.commands.get(id);
453
+ if (!commands2) {
454
+ commands2 = new LinkedList();
455
+ this.commands.set(id, commands2);
456
+ }
457
+ const removeFn = commands2.unshift(idOrCommand);
458
+ const ret = toDisposable(() => {
459
+ removeFn();
460
+ const command = this.commands.get(id);
461
+ if (command == null ? void 0 : command.isEmpty()) {
462
+ this.commands.delete(id);
463
+ }
464
+ });
465
+ return ret;
466
+ }
467
+ /**
468
+ * 指令是否已经注册
469
+ *
470
+ * @author chitanda
471
+ * @date 2022-07-21 15:07:58
472
+ * @param {string} id
473
+ * @return {*} {boolean}
474
+ */
475
+ hasCommand(id) {
476
+ return this.commands.has(id);
477
+ }
478
+ /**
479
+ * 查找指令
480
+ *
481
+ * @author chitanda
482
+ * @date 2022-07-21 16:07:12
483
+ * @param {string} id
484
+ * @return {*} {(ICommand | undefined)}
485
+ */
486
+ getCommand(id) {
487
+ const list = this.commands.get(id);
488
+ if (!list || list.isEmpty()) {
489
+ return void 0;
490
+ }
491
+ return list[Symbol.iterator]().next().value;
492
+ }
493
+ /**
494
+ * 获取所有指令
495
+ *
496
+ * @author chitanda
497
+ * @date 2022-07-21 16:07:20
498
+ * @return {*} {ICommandsMap}
499
+ */
500
+ getCommands() {
501
+ const result = /* @__PURE__ */ new Map();
502
+ const keys = this.commands.keys();
503
+ for (const key of keys) {
504
+ const command = this.getCommand(key);
505
+ if (command) {
506
+ result.set(key, command);
507
+ }
508
+ }
509
+ return result;
510
+ }
511
+ /**
512
+ * 获取指令配置参数
513
+ *
514
+ * @author chitanda
515
+ * @date 2022-07-21 16:07:27
516
+ * @param {string} id
517
+ * @return {*} {(ICommandOption | undefined)}
518
+ */
519
+ getCommandOpt(id) {
520
+ const cmd = this.getCommand(id);
521
+ return cmd == null ? void 0 : cmd.opts;
522
+ }
523
+ };
524
+
525
+ // src/command/command.ts
526
+ var CommandController = class {
527
+ constructor() {
528
+ this.commandRegister = new CommandsRegistry();
529
+ }
530
+ /**
531
+ * 注册指令
532
+ *
533
+ * @author chitanda
534
+ * @date 2022-06-28 19:06:45
535
+ * @param {string} id
536
+ * @param {ICommandHandler} handler
537
+ * @param {ICommandOption} [opts]
538
+ * @return {*} {IDisposable}
539
+ */
540
+ register(id, handler, opts) {
541
+ return this.commandRegister.registerCommand(id, handler, opts);
542
+ }
543
+ /**
544
+ * 执行指令
545
+ *
546
+ * @author chitanda
547
+ * @date 2022-06-28 19:06:38
548
+ * @template T
549
+ * @param {string} id
550
+ * @param {...unknown[]} args
551
+ * @return {*} {Promise<T>}
552
+ */
553
+ async execute(id, ...args) {
554
+ const command = this.commandRegister.getCommand(id);
555
+ if (command) {
556
+ return command.handler(...args);
557
+ }
558
+ throw new Error(`\u672A\u6CE8\u518C\u6307\u4EE4: ${id}\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4`);
559
+ }
560
+ /**
561
+ * 判断指令是否存在,可直接抛出异常
562
+ *
563
+ * @author chitanda
564
+ * @date 2022-06-28 19:06:11
565
+ * @param {string} id
566
+ * @param {boolean} [err]
567
+ * @return {*} {boolean}
568
+ */
569
+ hasCommand(id, err) {
570
+ const bol = !!this.commandRegister.hasCommand(id);
571
+ if (err === true && bol === true) {
572
+ throw new Error(`\u672A\u6CE8\u518C\u6307\u4EE4: ${id}\uFF0C\u8BF7\u5148\u6CE8\u518C\u6307\u4EE4`);
573
+ }
574
+ return bol;
575
+ }
576
+ /**
577
+ * 获取指令配置参数
578
+ *
579
+ * @author chitanda
580
+ * @date 2022-07-21 17:07:11
581
+ * @param {string} id
582
+ * @return {*} {(ICommandOption | undefined)}
583
+ */
584
+ getCommandOpts(id) {
585
+ return this.commandRegister.getCommandOpt(id);
586
+ }
587
+ };
588
+
589
+ // src/command/index.ts
590
+ var commands = new CommandController();
591
+
592
+ // src/constant/core/core.ts
593
+ var CoreConst = class {
594
+ };
595
+ /**
596
+ * 默认模型服务标识
597
+ */
598
+ CoreConst.DEFAULT_MODEL_SERVICE_TAG = "default";
599
+ /**
600
+ * 访问令牌标识
601
+ *
602
+ * @author chitanda
603
+ * @date 2022-07-20 15:07:28
604
+ * @static
605
+ */
606
+ CoreConst.TOKEN = "access_token";
607
+ /**
608
+ * 访问令牌标识过期时间
609
+ *
610
+ * @author lxm
611
+ * @date 2023-02-13 07:11:33
612
+ * @static
613
+ * @memberof CoreConst
614
+ */
615
+ CoreConst.TOKEN_EXPIRES = "access_token_expires";
616
+
617
+ // src/constant/util/util.ts
618
+ var NOOP = () => {
619
+ };
620
+
621
+ // src/constant/http-status-message/http-status-message.ts
622
+ var HttpStatusMessageConst = {
623
+ 200: "\u670D\u52A1\u5668\u6210\u529F\u8FD4\u56DE\u8BF7\u6C42\u7684\u6570\u636E\u3002",
624
+ 201: "\u65B0\u5EFA\u6216\u4FEE\u6539\u6570\u636E\u6210\u529F\u3002",
625
+ 202: "\u4E00\u4E2A\u8BF7\u6C42\u5DF2\u7ECF\u8FDB\u5165\u540E\u53F0\u6392\u961F\uFF08\u5F02\u6B65\u4EFB\u52A1\uFF09\u3002",
626
+ 204: "\u5220\u9664\u6570\u636E\u6210\u529F\u3002",
627
+ 400: "\u53D1\u51FA\u7684\u8BF7\u6C42\u6709\u9519\u8BEF\uFF0C\u670D\u52A1\u5668\u6CA1\u6709\u8FDB\u884C\u65B0\u5EFA\u6216\u4FEE\u6539\u6570\u636E\u7684\u64CD\u4F5C\u3002",
628
+ 401: "\u7528\u6237\u6CA1\u6709\u6743\u9650\uFF08\u4EE4\u724C\u3001\u7528\u6237\u540D\u3001\u5BC6\u7801\u9519\u8BEF\uFF09\u3002",
629
+ 403: "\u7528\u6237\u5F97\u5230\u6388\u6743\uFF0C\u4F46\u662F\u8BBF\u95EE\u662F\u88AB\u7981\u6B62\u7684\u3002",
630
+ 404: "\u53D1\u51FA\u7684\u8BF7\u6C42\u9488\u5BF9\u7684\u662F\u4E0D\u5B58\u5728\u7684\u8BB0\u5F55\uFF0C\u670D\u52A1\u5668\u6CA1\u6709\u8FDB\u884C\u64CD\u4F5C\u3002",
631
+ 406: "\u8BF7\u6C42\u7684\u683C\u5F0F\u4E0D\u53EF\u5F97\u3002",
632
+ 410: "\u8BF7\u6C42\u7684\u8D44\u6E90\u88AB\u6C38\u4E45\u5220\u9664\uFF0C\u4E14\u4E0D\u4F1A\u518D\u5F97\u5230\u7684\u3002",
633
+ 422: "\u5F53\u521B\u5EFA\u4E00\u4E2A\u5BF9\u8C61\u65F6\uFF0C\u53D1\u751F\u4E00\u4E2A\u9A8C\u8BC1\u9519\u8BEF\u3002",
634
+ 500: "\u670D\u52A1\u5668\u53D1\u751F\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u5668\u3002",
635
+ 502: "\u7F51\u5173\u9519\u8BEF\u3002",
636
+ 503: "\u670D\u52A1\u4E0D\u53EF\u7528\uFF0C\u670D\u52A1\u5668\u6682\u65F6\u8FC7\u8F7D\u6216\u7EF4\u62A4\u3002",
637
+ 504: "\u7F51\u5173\u8D85\u65F6\u3002"
638
+ };
639
+
640
+ // src/constant/login-mode/login-mode.ts
641
+ var LoginMode = /* @__PURE__ */ ((LoginMode2) => {
642
+ LoginMode2["DEFAULT"] = "DEFAULT";
643
+ LoginMode2["CUSTOM"] = "CUSTOM";
644
+ LoginMode2["CAS"] = "CAS";
645
+ return LoginMode2;
646
+ })(LoginMode || {});
647
+
648
+ // src/constant/menu-permission-mode/menu-permission-mode.ts
649
+ var MenuPermissionMode = /* @__PURE__ */ ((MenuPermissionMode2) => {
650
+ MenuPermissionMode2["MIXIN"] = "MIXIN";
651
+ MenuPermissionMode2["RESOURCE"] = "RESOURCE";
652
+ MenuPermissionMode2["RT"] = "RT";
653
+ return MenuPermissionMode2;
654
+ })(MenuPermissionMode || {});
655
+
656
+ // src/context/index.ts
657
+ import { clone } from "ramda";
658
+ var IBizContext = class {
659
+ /**
660
+ * Creates an instance of IBizContext.
661
+ *
662
+ * @author chitanda
663
+ * @date 2022-07-14 10:07:15
664
+ * @param {IDatum} [context={}] 自身的上下文
665
+ * @param {IContext} [parent]
666
+ */
667
+ // eslint-disable-next-line default-param-last
668
+ constructor(context = {}, parent) {
669
+ Object.defineProperty(this, "_associationContext", {
670
+ enumerable: false,
671
+ value: []
672
+ });
673
+ 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);
706
+ }
707
+ Object.assign(this, context);
708
+ }
709
+ /**
710
+ * 返回自身的上下文,独有的和与父有差异的。
711
+ *
712
+ * @author lxm
713
+ * @date 2022-12-08 17:12:26
714
+ * @returns {*} {IDatum}
715
+ */
716
+ getOwnContext() {
717
+ const result = {};
718
+ Object.keys(this).forEach((key) => {
719
+ if (!this._parent || !Object.prototype.hasOwnProperty.call(this._parent, key) || Object.prototype.hasOwnProperty.call(this._context, key)) {
720
+ result[key] = this[key];
721
+ }
722
+ });
723
+ return result;
724
+ }
725
+ /**
726
+ * 销毁当前上下文对象
727
+ *
728
+ * @author chitanda
729
+ * @date 2023-03-13 15:03:04
730
+ */
731
+ destroy() {
732
+ this._parent = void 0;
733
+ this._context = {};
734
+ this._associationContext.forEach((item) => {
735
+ item.destroy();
736
+ });
737
+ }
738
+ /**
739
+ * 在非视图中,需要断开视图上下文联系时。只能使用 clone 创建新的局部上下文
740
+ *
741
+ * @author chitanda
742
+ * @date 2023-03-13 16:03:13
743
+ * @return {*} {IBizContext}
744
+ */
745
+ clone() {
746
+ const newContext = new IBizContext(
747
+ clone(this.getOwnContext()),
748
+ this._parent
749
+ );
750
+ this._associationContext.push(newContext);
751
+ return newContext;
752
+ }
753
+ /**
754
+ * 上下文只有在视图初始化时,调用 create 方法
755
+ *
756
+ * @author chitanda
757
+ * @date 2023-03-13 16:03:32
758
+ * @static
759
+ * @param {IDatum} [context]
760
+ * @param {IContext} [parent]
761
+ * @return {*} {IContext}
762
+ */
763
+ static create(context, parent) {
764
+ return new IBizContext(context, parent);
765
+ }
766
+ };
767
+
768
+ // src/environment/environment.ts
769
+ var Environment = {
770
+ dev: false,
771
+ hub: true,
772
+ logLevel: "ERROR",
773
+ baseUrl: "/api",
774
+ appId: "",
775
+ pluginBaseUrl: "./plugins",
776
+ remoteModelUrl: "/remotemodel",
777
+ assetsUrl: "./assets",
778
+ dcSystem: "",
779
+ downloadFileUrl: "/ibizutil/download",
780
+ uploadFileUrl: "/ibizutil/upload",
781
+ casLoginUrl: "",
782
+ loginMode: "DEFAULT" /* DEFAULT */,
783
+ menuPermissionMode: "MIXIN" /* MIXIN */,
784
+ enablePermission: true,
785
+ routePlaceholder: "-",
786
+ enableWfAllHistory: false
787
+ };
788
+
789
+ // src/error/http-error/http-error.ts
790
+ var HttpError = class {
791
+ constructor(err) {
792
+ this.name = "HttpError";
793
+ const res = err.response;
794
+ this.response = err.response;
795
+ if (res) {
796
+ if (res.data) {
797
+ this.message = res.data.message;
798
+ } else {
799
+ this.message = res.statusText;
800
+ }
801
+ if (!this.message) {
802
+ this.message = "\u7F51\u7EDC\u5F02\u5E38\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5!";
803
+ }
804
+ this.status = res.status;
805
+ } else {
806
+ this.message = err.message;
807
+ this.status = 500;
808
+ }
809
+ }
810
+ };
811
+
812
+ // src/error/model-error/model-error.ts
813
+ var ModelError = class extends Error {
814
+ /**
815
+ * Creates an instance of ModelError.
816
+ *
817
+ * @author chitanda
818
+ * @date 2022-08-30 16:08:38
819
+ * @param {IModelObject} model 模板未支持的模型
820
+ * @param {string} [msg]
821
+ */
822
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
823
+ constructor(model, msg) {
824
+ super(`\u300C${model.id}\u300D\u6A21\u578B${msg ? `\uFF1A ${msg}` : ""}`);
825
+ this.model = model;
826
+ this.name = "\u672A\u652F\u6301\u7684\u6A21\u578B";
827
+ }
828
+ };
829
+
830
+ // src/error/runtime-error/runtime-error.ts
831
+ var RuntimeError = class {
832
+ constructor(message) {
833
+ this.message = message;
834
+ this.name = "Runtime Error";
835
+ }
836
+ };
837
+
838
+ // src/error/runtime-model-error/runtime-model-error.ts
839
+ var RuntimeModelError = class extends Error {
840
+ /**
841
+ * Creates an instance of DefectModelError.
842
+ *
843
+ * @author chitanda
844
+ * @date 2022-08-30 16:08:58
845
+ * @param {IModelObject} model 丢失配置的模型
846
+ * @param {string} [msg] 缺失配置描述
847
+ */
848
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
849
+ constructor(model, msg) {
850
+ super(`\u300C${model.id}\u300D\u6A21\u578B${msg ? `\uFF1A ${msg}` : ""}`);
851
+ this.model = model;
852
+ this.name = "\u6A21\u578B\u914D\u7F6E\u7F3A\u5931";
853
+ }
854
+ };
855
+
856
+ // src/utils/util/util.ts
857
+ import { debounce as debounce2 } from "lodash-es";
858
+ import { getCookie } from "qx-util";
859
+ function getToken() {
860
+ return getCookie(CoreConst.TOKEN);
861
+ }
862
+ function isOverlap(arr1, arr2) {
863
+ const newArr = Array.from(/* @__PURE__ */ new Set([...arr1, ...arr2]));
864
+ return newArr.length !== arr1.length + arr2.length;
865
+ }
866
+ function debounceAndMerge(func, mergeFunc, wait) {
867
+ let oldParams;
868
+ const debounceFunc = debounce2((...params) => {
869
+ oldParams = void 0;
870
+ return func(...params);
871
+ }, wait);
872
+ return (...args) => {
873
+ let newParams = args;
874
+ if (oldParams) {
875
+ newParams = mergeFunc(oldParams, newParams);
876
+ }
877
+ oldParams = newParams;
878
+ return debounceFunc(...newParams);
879
+ };
880
+ }
881
+ function debounceAndAsyncMerge(func, mergeFunc, wait) {
882
+ let oldParams;
883
+ let promises = [];
884
+ const debounceFunc = debounce2(async (...params) => {
885
+ oldParams = void 0;
886
+ try {
887
+ const result = await func(...params);
888
+ promises.forEach((promise) => {
889
+ promise.resolve(result);
890
+ });
891
+ promises = [];
892
+ return result;
893
+ } catch (error) {
894
+ promises.forEach((promise) => {
895
+ promise.reject(error);
896
+ });
897
+ promises = [];
898
+ }
899
+ }, wait);
900
+ const fun = async (...args) => {
901
+ let newParams = args;
902
+ if (oldParams) {
903
+ newParams = mergeFunc(oldParams, newParams);
904
+ }
905
+ oldParams = newParams;
906
+ debounceFunc(...newParams);
907
+ return new Promise((resolve, reject) => {
908
+ promises.push({ resolve, reject });
909
+ });
910
+ };
911
+ return fun;
912
+ }
913
+
914
+ // src/utils/interceptor/interceptor.ts
915
+ var Interceptor = class {
916
+ /**
917
+ * 请求之前处理
918
+ *
919
+ * @author lxm
920
+ * @date 2022-10-27 17:10:41
921
+ * @protected
922
+ * @param {InternalAxiosRequestConfig} config
923
+ * @returns {*} {Promise<InternalAxiosRequestConfig>}
924
+ */
925
+ async onBeforeRequest(config) {
926
+ return config;
927
+ }
928
+ /**
929
+ * 请求失败之后处理
930
+ *
931
+ * @author lxm
932
+ * @date 2022-10-27 17:10:40
933
+ * @protected
934
+ * @param {*} error
935
+ */
936
+ onRequestError(error) {
937
+ return Promise.reject(error);
938
+ }
939
+ /**
940
+ * 响应成功之后处理
941
+ *
942
+ * @author lxm
943
+ * @date 2022-10-27 17:10:38
944
+ * @protected
945
+ * @param {AxiosResponse} config
946
+ * @returns {*} {Promise<AxiosRequestConfig>}
947
+ */
948
+ async onResponseSuccess(config) {
949
+ return config;
950
+ }
951
+ /**
952
+ * 响应失败之后处理
953
+ *
954
+ * @author lxm
955
+ * @date 2022-10-27 17:10:37
956
+ * @protected
957
+ * @param {*} _error
958
+ */
959
+ onResponseError(error) {
960
+ return Promise.reject(error);
961
+ }
962
+ /**
963
+ * 使用拦截器
964
+ *
965
+ * @author lxm
966
+ * @date 2022-10-27 17:10:28
967
+ * @param {AxiosInstance} instance
968
+ */
969
+ use(instance) {
970
+ this.requestTag = instance.interceptors.request.use(
971
+ this.onBeforeRequest,
972
+ this.onRequestError
973
+ );
974
+ this.responseTag = instance.interceptors.response.use(
975
+ this.onResponseSuccess,
976
+ this.onResponseError
977
+ );
978
+ }
979
+ /**
980
+ * 移出拦截器
981
+ *
982
+ * @author lxm
983
+ * @date 2022-10-27 17:10:27
984
+ * @param {AxiosInstance} instance
985
+ */
986
+ eject(instance) {
987
+ if (this.requestTag) {
988
+ instance.interceptors.request.eject(this.requestTag);
989
+ }
990
+ if (this.responseTag) {
991
+ instance.interceptors.response.eject(this.responseTag);
992
+ }
993
+ }
994
+ };
995
+
996
+ // src/utils/interceptor/core-interceptor.ts
997
+ var CoreInterceptor = class extends Interceptor {
998
+ async onBeforeRequest(config) {
999
+ await super.onBeforeRequest(config);
1000
+ const { headers } = config;
1001
+ headers.set("Authorization", `Bearer ${getToken()}`);
1002
+ const { orgData } = ibiz;
1003
+ if (orgData) {
1004
+ if (orgData.systemid) {
1005
+ headers.set("srfsystemid", orgData.systemid);
1006
+ }
1007
+ if (orgData.orgid) {
1008
+ headers.set("srforgid", orgData.orgid);
1009
+ }
1010
+ }
1011
+ return config;
1012
+ }
1013
+ };
1014
+
1015
+ // src/utils/logger/logger.ts
1016
+ var Logger = __toESM(require_loglevel(), 1);
1017
+
1018
+ // src/utils/namespace/namespace.ts
1019
+ var defaultNamespace = "ibiz";
1020
+ var statePrefix = "is-";
1021
+ function _bem(namespace, block, blockSuffix, element, modifier) {
1022
+ let cls = `${namespace}-${block}`;
1023
+ if (blockSuffix) {
1024
+ cls += `-${blockSuffix}`;
1025
+ }
1026
+ if (element) {
1027
+ cls += `__${element}`;
1028
+ }
1029
+ if (modifier) {
1030
+ cls += `--${modifier}`;
1031
+ }
1032
+ return cls;
1033
+ }
1034
+ var Namespace = class {
1035
+ /**
1036
+ * Creates an instance of Namespace.
1037
+ *
1038
+ * @author chitanda
1039
+ * @date 2022-09-06 12:09:12
1040
+ * @param {string} block 当前命名空间的根模块,例如组件的名称
1041
+ * @param {string} [namespace] 指定命名空间,未指定使用默认值 ibiz
1042
+ */
1043
+ constructor(block, namespace) {
1044
+ this.block = block;
1045
+ this.namespace = namespace || defaultNamespace;
1046
+ }
1047
+ /**
1048
+ * namespace-block
1049
+ * namespace-block-blockSuffix
1050
+ *
1051
+ * @author chitanda
1052
+ * @date 2022-09-06 12:09:08
1053
+ * @param {string} [blockSuffix='']
1054
+ * @return {*} {string}
1055
+ */
1056
+ b(blockSuffix = "") {
1057
+ return _bem(this.namespace, this.block, blockSuffix, "", "");
1058
+ }
1059
+ /**
1060
+ * namespace-block__element
1061
+ *
1062
+ * @author chitanda
1063
+ * @date 2022-09-06 12:09:48
1064
+ * @param {string} [element]
1065
+ * @return {*} {string}
1066
+ */
1067
+ e(element) {
1068
+ return element ? _bem(this.namespace, this.block, "", element, "") : "";
1069
+ }
1070
+ /**
1071
+ * namespace-block--modifier
1072
+ *
1073
+ * @author chitanda
1074
+ * @date 2022-09-06 12:09:37
1075
+ * @param {string} [modifier]
1076
+ * @return {*} {string}
1077
+ */
1078
+ m(modifier) {
1079
+ return modifier ? _bem(this.namespace, this.block, "", "", modifier) : "";
1080
+ }
1081
+ /**
1082
+ * namespace-block-blockSuffix__element
1083
+ *
1084
+ * @author chitanda
1085
+ * @date 2022-09-06 12:09:52
1086
+ * @param {string} [blockSuffix]
1087
+ * @param {string} [element]
1088
+ * @return {*} {string}
1089
+ */
1090
+ be(blockSuffix, element) {
1091
+ return blockSuffix && element ? _bem(this.namespace, this.block, blockSuffix, element, "") : "";
1092
+ }
1093
+ /**
1094
+ * namespace-block__element--modifier
1095
+ *
1096
+ * @author chitanda
1097
+ * @date 2022-09-06 12:09:19
1098
+ * @param {string} [element]
1099
+ * @param {string} [modifier]
1100
+ * @return {*} {string}
1101
+ */
1102
+ em(element, modifier) {
1103
+ return element && modifier ? _bem(this.namespace, this.block, "", element, modifier) : "";
1104
+ }
1105
+ /**
1106
+ * namespace-block-blockSuffix--modifier
1107
+ *
1108
+ * @author chitanda
1109
+ * @date 2022-09-06 12:09:59
1110
+ * @param {string} [blockSuffix]
1111
+ * @param {string} [modifier]
1112
+ * @return {*} {string}
1113
+ */
1114
+ bm(blockSuffix, modifier) {
1115
+ return blockSuffix && modifier ? _bem(this.namespace, this.block, blockSuffix, "", modifier) : "";
1116
+ }
1117
+ /**
1118
+ * namespace-block-blockSuffix__element--modifier
1119
+ *
1120
+ * @author chitanda
1121
+ * @date 2022-09-06 12:09:37
1122
+ * @param {string} [blockSuffix]
1123
+ * @param {string} [element]
1124
+ * @param {string} [modifier]
1125
+ * @return {*} {string}
1126
+ */
1127
+ bem(blockSuffix, element, modifier) {
1128
+ return blockSuffix && element && modifier ? _bem(this.namespace, this.block, blockSuffix, element, modifier) : "";
1129
+ }
1130
+ /**
1131
+ * 返回状态 class
1132
+ *
1133
+ * is('loading', false) => '';
1134
+ * is('loading', true) => 'is-loading';
1135
+ *
1136
+ * @author chitanda
1137
+ * @date 2022-09-06 12:09:57
1138
+ * @param {string} name
1139
+ * @param {boolean} [state]
1140
+ * @return {*} {string}
1141
+ */
1142
+ is(name, state) {
1143
+ return name && state ? `${statePrefix}${name}` : "";
1144
+ }
1145
+ /**
1146
+ * 生成使用到的 css 变量 style 对象
1147
+ *
1148
+ * @author chitanda
1149
+ * @date 2022-09-06 15:09:41
1150
+ * @param {Record<string, string>} object
1151
+ * @return {*} {Record<string, string>}
1152
+ */
1153
+ cssVar(object) {
1154
+ const styles = {};
1155
+ for (const key in object) {
1156
+ if (object[key]) {
1157
+ styles[this.cssVarName(key)] = object[key];
1158
+ }
1159
+ }
1160
+ return styles;
1161
+ }
1162
+ /**
1163
+ * 生成使用到的 css block 变量 style 对象
1164
+ *
1165
+ * @author chitanda
1166
+ * @date 2022-09-06 15:09:03
1167
+ * @param {Record<string, string>} object
1168
+ * @return {*} {Record<string, string>}
1169
+ */
1170
+ cssVarBlock(object) {
1171
+ const styles = {};
1172
+ for (const key in object) {
1173
+ if (object[key]) {
1174
+ styles[this.cssVarBlockName(key)] = object[key];
1175
+ }
1176
+ }
1177
+ return styles;
1178
+ }
1179
+ /**
1180
+ * 生成 css var 变量名称
1181
+ *
1182
+ * @author chitanda
1183
+ * @date 2022-09-06 15:09:21
1184
+ * @param {string} name
1185
+ * @return {*} {string}
1186
+ */
1187
+ cssVarName(name) {
1188
+ return `--${this.namespace}-${name}`;
1189
+ }
1190
+ /**
1191
+ * 生成块 css var 变量名称
1192
+ *
1193
+ * @author chitanda
1194
+ * @date 2022-09-06 15:09:35
1195
+ * @param {string} name
1196
+ * @return {*} {string}
1197
+ */
1198
+ cssVarBlockName(name) {
1199
+ return `--${this.namespace}-${this.block}-${name}`;
1200
+ }
1201
+ };
1202
+
1203
+ // src/utils/net/http-response.ts
1204
+ import {
1205
+ AxiosHeaders
1206
+ } from "axios";
1207
+ var HttpResponse = class {
1208
+ /**
1209
+ * Creates an instance of HttpResponse.
1210
+ *
1211
+ * @author chitanda
1212
+ * @date 2022-08-18 15:08:11
1213
+ * @param {unknown} [data] 返回的数据
1214
+ * @param {number} [status] 状态码 (默认为 200)
1215
+ * @param {string} [statusText] 状态描述 (默认为空字符)
1216
+ */
1217
+ constructor(data, status, statusText) {
1218
+ /**
1219
+ * 本地仿造响应
1220
+ *
1221
+ * @author chitanda
1222
+ * @date 2022-08-18 15:08:06
1223
+ */
1224
+ this.local = true;
1225
+ this.ok = false;
1226
+ this.headers = {};
1227
+ this.config = {
1228
+ headers: new AxiosHeaders()
1229
+ };
1230
+ this.data = data;
1231
+ this.status = status || 200;
1232
+ this.statusText = statusText || "";
1233
+ if (this.status >= 200 && this.status < 300) {
1234
+ this.ok = true;
1235
+ }
1236
+ }
1237
+ };
1238
+
1239
+ // src/utils/net/net.ts
1240
+ import axios from "axios";
1241
+ import { merge } from "lodash-es";
1242
+ import { stringify } from "qs";
1243
+ import { notNilEmpty } from "qx-util";
1244
+ var Net = class {
1245
+ /**
1246
+ * Creates an instance of Net.
1247
+ * @author lxm
1248
+ * @date 2022-10-27 16:10:05
1249
+ * @param {CreateAxiosDefaults} [config] 创建实例用的默认配置
1250
+ */
1251
+ constructor(config) {
1252
+ /**
1253
+ * 是否为 http || https 开头
1254
+ *
1255
+ * @author chitanda
1256
+ * @date 2022-11-07 14:11:28
1257
+ * @protected
1258
+ */
1259
+ this.urlReg = /^http[s]?:\/\/[^\s]*/;
1260
+ /**
1261
+ * 注册的拦截器
1262
+ *
1263
+ * @author lxm
1264
+ * @date 2022-10-27 17:10:18
1265
+ * @type {Map<string, Interceptor>}
1266
+ */
1267
+ this.interceptors = /* @__PURE__ */ new Map();
1268
+ this.instance = axios.create(config);
1269
+ this.addInterceptor("Default", new CoreInterceptor());
1270
+ }
1271
+ /**
1272
+ * 添加拦截器
1273
+ *
1274
+ * @author lxm
1275
+ * @date 2022-10-27 17:10:42
1276
+ * @param {string} name 唯一标识
1277
+ * @param {Interceptor} interceptor 拦截器
1278
+ */
1279
+ addInterceptor(name, interceptor) {
1280
+ interceptor.use(this.instance);
1281
+ this.interceptors.set(name, interceptor);
1282
+ }
1283
+ /**
1284
+ * 删除拦截器
1285
+ *
1286
+ * @author lxm
1287
+ * @date 2022-10-27 17:10:27
1288
+ * @param {string} name 唯一标识
1289
+ */
1290
+ removeInterceptor(name) {
1291
+ const interceptor = this.interceptors.get(name);
1292
+ if (interceptor) {
1293
+ interceptor.eject(this.instance);
1294
+ this.interceptors.delete(name);
1295
+ }
1296
+ }
1297
+ /**
1298
+ * 预置config,绑定动态的配置
1299
+ *
1300
+ * @author lxm
1301
+ * @date 2022-10-27 16:10:48
1302
+ * @readonly
1303
+ * @protected
1304
+ * @type {AxiosRequestConfig}
1305
+ */
1306
+ get presetConfig() {
1307
+ return {
1308
+ // 请求前缀路径
1309
+ baseURL: this.instance.defaults.baseURL || `${ibiz.env.baseUrl}/${ibiz.env.appId}`,
1310
+ headers: {
1311
+ "Content-Type": "application/json;charset=UTF-8",
1312
+ Accept: "application/json"
1313
+ }
1314
+ };
1315
+ }
1316
+ /**
1317
+ * 从左到右递归合并配置参数(内置第一个合并的预置参数)
1318
+ *
1319
+ * @author lxm
1320
+ * @date 2022-10-27 16:10:09
1321
+ * @protected
1322
+ * @param {...AxiosRequestConfig[]} configs
1323
+ * @returns {*}
1324
+ */
1325
+ mergeConfig(...configs) {
1326
+ const config = this.presetConfig;
1327
+ if (configs.length === 0) {
1328
+ return config;
1329
+ }
1330
+ const { url } = configs[0];
1331
+ if (url && this.urlReg.test(url)) {
1332
+ delete config.baseURL;
1333
+ }
1334
+ return merge(config, ...configs);
1335
+ }
1336
+ /**
1337
+ * Post 请求
1338
+ *
1339
+ * @author chitanda
1340
+ * @date 2022-10-19 11:10:30
1341
+ * @param {string} url
1342
+ * @param {IData} data
1343
+ * @param {IParams} [params={}]
1344
+ * @param {RawAxiosRequestHeaders} [headers={}]
1345
+ * @return {*} {Promise<IHttpResponse>}
1346
+ */
1347
+ async post(url, data, params = {}, headers = {}) {
1348
+ url = this.handleAppPresetParam(url, params);
1349
+ try {
1350
+ const response = await this.request(url, {
1351
+ method: "post",
1352
+ data,
1353
+ headers
1354
+ });
1355
+ return this.doResponseResult(response);
1356
+ } catch (error) {
1357
+ throw new HttpError(error);
1358
+ }
1359
+ }
1360
+ /**
1361
+ * Get 请求
1362
+ *
1363
+ * @author chitanda
1364
+ * @date 2022-10-19 11:10:24
1365
+ * @param {string} url
1366
+ * @param {IParams} [params={}]
1367
+ * @param {RawAxiosRequestHeaders} [headers={}]
1368
+ * @param {IParams} [option={}]
1369
+ * @return {*} {Promise<IHttpResponse>}
1370
+ */
1371
+ async get(url, params = {}, headers = {}, option = {}) {
1372
+ url = this.attachUrlParam(url, params);
1373
+ try {
1374
+ const response = await this.request(
1375
+ url,
1376
+ merge({ method: "get", headers }, option)
1377
+ );
1378
+ return this.doResponseResult(response);
1379
+ } catch (error) {
1380
+ throw new HttpError(error);
1381
+ }
1382
+ }
1383
+ /**
1384
+ * Delete 请求
1385
+ *
1386
+ * @author chitanda
1387
+ * @date 2022-10-19 11:10:17
1388
+ * @param {string} url
1389
+ * @param {IParams} [params]
1390
+ * @param {RawAxiosRequestHeaders} [headers={}]
1391
+ * @return {*} {Promise<IHttpResponse>}
1392
+ */
1393
+ async delete(url, params, headers = {}) {
1394
+ url = this.handleAppPresetParam(url, params);
1395
+ try {
1396
+ const response = await this.request(url, { method: "delete", headers });
1397
+ return this.doResponseResult(response);
1398
+ } catch (error) {
1399
+ throw new HttpError(error);
1400
+ }
1401
+ }
1402
+ /**
1403
+ * Put 请求
1404
+ *
1405
+ * @author chitanda
1406
+ * @date 2022-10-19 11:10:11
1407
+ * @param {string} url
1408
+ * @param {IData} data
1409
+ * @param {IParams} [params={}]
1410
+ * @param {RawAxiosRequestHeaders} [headers={}]
1411
+ * @return {*} {Promise<IHttpResponse>}
1412
+ */
1413
+ async put(url, data, params = {}, headers = {}) {
1414
+ url = this.handleAppPresetParam(url, params);
1415
+ try {
1416
+ const response = await this.request(url, {
1417
+ method: "put",
1418
+ data,
1419
+ headers
1420
+ });
1421
+ return this.doResponseResult(response);
1422
+ } catch (error) {
1423
+ throw new HttpError(error);
1424
+ }
1425
+ }
1426
+ /**
1427
+ * 获取模型数据
1428
+ *
1429
+ * @author chitanda
1430
+ * @date 2022-07-14 15:07:15
1431
+ * @param {string} url
1432
+ * @param {RawAxiosRequestHeaders} [headers={}]
1433
+ * @return {*} {Promise<IHttpResponse>}
1434
+ */
1435
+ async getModel(url, headers = {}) {
1436
+ try {
1437
+ const response = await this.instance.get(url, {
1438
+ headers
1439
+ });
1440
+ return this.doResponseResult(response);
1441
+ } catch (error) {
1442
+ throw new HttpError(error);
1443
+ }
1444
+ }
1445
+ /**
1446
+ * 基础请求方法,会合并预置配置
1447
+ *
1448
+ * @author lxm
1449
+ * @date 2022-10-27 14:10:06
1450
+ * @param {string} url
1451
+ * @param {AxiosRequestConfig} [config={}]
1452
+ * @returns {*} {Promise<IHttpResponse>}
1453
+ */
1454
+ async request(url, config = {}) {
1455
+ try {
1456
+ const response = await this.instance.request(
1457
+ this.mergeConfig({ url }, config)
1458
+ );
1459
+ return this.doResponseResult(response);
1460
+ } catch (error) {
1461
+ throw new HttpError(error);
1462
+ }
1463
+ }
1464
+ /**
1465
+ * 创建标准 axios 请求
1466
+ *
1467
+ * @author chitanda
1468
+ * @date 2023-01-30 15:01:27
1469
+ * @param {AxiosRequestConfig<IData>} config
1470
+ * @return {*}
1471
+ */
1472
+ axios(config) {
1473
+ return axios(config);
1474
+ }
1475
+ /**
1476
+ * 统一处理请求返回
1477
+ *
1478
+ * @author chitanda
1479
+ * @date 2022-07-14 16:07:23
1480
+ * @private
1481
+ * @param {AxiosResponse} response
1482
+ * @return {*} {IHttpResponse}
1483
+ */
1484
+ doResponseResult(response) {
1485
+ const res = response;
1486
+ if (res.status >= 200 && res.status <= 299) {
1487
+ res.ok = true;
1488
+ }
1489
+ return res;
1490
+ }
1491
+ /**
1492
+ * 处理平台预定义参数
1493
+ *
1494
+ * @author chitanda
1495
+ * @date 2022-07-14 15:07:12
1496
+ * @private
1497
+ * @param {string} url
1498
+ * @param {IParams} [params]
1499
+ * @return {*} {string}
1500
+ */
1501
+ handleAppPresetParam(url, params) {
1502
+ if (params) {
1503
+ const keys = Object.keys(params);
1504
+ const tempParam = {};
1505
+ keys.forEach((item) => {
1506
+ if (item.startsWith("srf") && notNilEmpty(params[item])) {
1507
+ tempParam[item] = params[item];
1508
+ }
1509
+ });
1510
+ return this.attachUrlParam(url, params);
1511
+ }
1512
+ return url;
1513
+ }
1514
+ /**
1515
+ * url 附加请求参数
1516
+ *
1517
+ * @author chitanda
1518
+ * @date 2022-07-14 15:07:34
1519
+ * @private
1520
+ * @param {string} url
1521
+ * @param {IParams} params
1522
+ * @return {*} {string}
1523
+ */
1524
+ attachUrlParam(url, params) {
1525
+ const strParams = stringify(params);
1526
+ if (notNilEmpty(strParams)) {
1527
+ if (url.endsWith("?")) {
1528
+ url = `${url}${strParams}`;
1529
+ } else if (url.indexOf("?") !== -1 && url.endsWith("&")) {
1530
+ url = `${url}${strParams}`;
1531
+ } else if (url.indexOf("?") !== -1 && !url.endsWith("&")) {
1532
+ url = `${url}&${strParams}`;
1533
+ } else {
1534
+ url = `${url}?${strParams}`;
1535
+ }
1536
+ }
1537
+ return url;
1538
+ }
1539
+ };
1540
+
1541
+ // src/utils/plural/plural.ts
1542
+ import pluralize from "pluralize";
1543
+ function plural(key) {
1544
+ return pluralize(key);
1545
+ }
1546
+ function pluralLower(key) {
1547
+ return plural(key).toLowerCase();
1548
+ }
1549
+
1550
+ // src/utils/string-util/string-util.ts
1551
+ import { notNilEmpty as notNilEmpty2 } from "qx-util";
1552
+ var StringUtil = class {
1553
+ /**
1554
+ * 填充字符串中的数据
1555
+ *
1556
+ * @author chitanda
1557
+ * @date 2021-04-23 20:04:17
1558
+ * @static
1559
+ * @param {string} str
1560
+ * @param {*} [context]
1561
+ * @param {*} [data]
1562
+ * @return {*} {string}
1563
+ */
1564
+ static fill(str, context, data) {
1565
+ if (notNilEmpty2(str)) {
1566
+ if (notNilEmpty2(context)) {
1567
+ const strArr = str.match(this.contextReg);
1568
+ strArr == null ? void 0 : strArr.forEach((_key) => {
1569
+ const key = _key.slice(10, _key.length - 1);
1570
+ str = str.replace(`\${context.${key}}`, context[key] || "");
1571
+ });
1572
+ }
1573
+ if (notNilEmpty2(data)) {
1574
+ const strArr = str.match(this.dataReg);
1575
+ strArr == null ? void 0 : strArr.forEach((_key) => {
1576
+ const key = _key.slice(7, _key.length - 1);
1577
+ str = str.replace(`\${data.${key}}`, data[key] || "");
1578
+ });
1579
+ }
1580
+ }
1581
+ return str;
1582
+ }
1583
+ };
1584
+ /**
1585
+ * 上下文替换正则
1586
+ *
1587
+ * @author chitanda
1588
+ * @date 2021-04-23 20:04:01
1589
+ * @static
1590
+ */
1591
+ StringUtil.contextReg = /\$\{context.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g;
1592
+ /**
1593
+ * 数据替换正则
1594
+ *
1595
+ * @author chitanda
1596
+ * @date 2021-04-23 20:04:09
1597
+ * @static
1598
+ */
1599
+ StringUtil.dataReg = /\$\{data.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g;
1600
+
1601
+ // src/utils/url-helper/url-helper.ts
1602
+ var UrlHelper = class {
1603
+ /**
1604
+ * 路由路径前面的基础路径
1605
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
1606
+ * 返回:http://172.16.103.120:30061/portalwebapp/#
1607
+ *
1608
+ * @author lxm
1609
+ * @date 2022-10-11 20:10:29
1610
+ * @returns {*}
1611
+ */
1612
+ static get routeBase() {
1613
+ return `${this.appBase}/#`;
1614
+ }
1615
+ /**
1616
+ * 应用的的基础路径
1617
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
1618
+ * 返回:http://172.16.103.120:30061/portalwebapp
1619
+ *
1620
+ * @author lxm
1621
+ * @date 2022-10-11 20:10:29
1622
+ * @returns {*}
1623
+ */
1624
+ static get appBase() {
1625
+ const { origin, pathname } = window.location;
1626
+ return `${origin}${pathname}`.replace(/\/$/, "");
1627
+ }
1628
+ /**
1629
+ * #开始到末尾,即路由地址
1630
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
1631
+ * 返回:/index/appportalview?params=123
1632
+ *
1633
+ * @author lxm
1634
+ * @date 2022-10-11 16:10:40
1635
+ * @returns {*}
1636
+ */
1637
+ static get routePath() {
1638
+ return window.location.hash.replace("#", "");
1639
+ }
1640
+ /**
1641
+ * 当前地址的全路径,包含域名和参数
1642
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
1643
+ *
1644
+ * @author lxm
1645
+ * @date 2022-10-11 21:10:39
1646
+ * @readonly
1647
+ * @static
1648
+ */
1649
+ static get fullPath() {
1650
+ return window.location.href;
1651
+ }
1652
+ };
1653
+
1654
+ // src/utils/event/event.ts
1655
+ function eventPath(event) {
1656
+ const path = event.composedPath && event.composedPath() || event.path;
1657
+ if (path != null)
1658
+ return path;
1659
+ function getParents(node, memo = []) {
1660
+ const parentNode = node.parentNode;
1661
+ return parentNode ? getParents(parentNode, memo.concat([parentNode])) : memo;
1662
+ }
1663
+ return [event.target].concat(getParents(event.target));
1664
+ }
1665
+ function listenJSEvent(target, eventName, listener, options = {}) {
1666
+ target.addEventListener(eventName, listener, options);
1667
+ let cleanup = () => {
1668
+ target.removeEventListener(eventName, listener, options);
1669
+ cleanup = NOOP;
1670
+ };
1671
+ return () => {
1672
+ cleanup();
1673
+ };
1674
+ }
1675
+ function isEventInside(event, el) {
1676
+ return el && (event.target === el || eventPath(event).includes(el));
1677
+ }
1678
+
1679
+ // src/utils/click-outside/click-outside.ts
1680
+ var defaultWindow = typeof window !== "undefined" ? window : void 0;
1681
+ function onClickOutside(target, handler, options = {}) {
1682
+ const { window: window2 = defaultWindow, ignore = [], capture = true } = options;
1683
+ if (!target)
1684
+ throw new RuntimeError("target\u5143\u7D20\u4E0D\u5B58\u5728");
1685
+ if (!window2)
1686
+ throw new RuntimeError("\u627E\u4E0D\u5230window");
1687
+ let shouldListen = true;
1688
+ const isOutside = (event) => {
1689
+ return ![target, ...ignore].some((el) => {
1690
+ return isEventInside(event, el);
1691
+ });
1692
+ };
1693
+ let isPaused = false;
1694
+ const pause = () => {
1695
+ isPaused = true;
1696
+ };
1697
+ const proceed = () => {
1698
+ isPaused = false;
1699
+ };
1700
+ let fallback;
1701
+ const listener = (event) => {
1702
+ if (isPaused)
1703
+ return;
1704
+ window2.clearTimeout(fallback);
1705
+ if (!(shouldListen && isOutside(event)))
1706
+ return;
1707
+ handler(event);
1708
+ };
1709
+ const cleanups = [
1710
+ listenJSEvent(window2, "click", listener, { passive: true, capture }),
1711
+ listenJSEvent(
1712
+ window2,
1713
+ "pointerdown",
1714
+ (e) => {
1715
+ if (isPaused)
1716
+ return;
1717
+ shouldListen = isOutside(e);
1718
+ },
1719
+ { passive: true }
1720
+ ),
1721
+ listenJSEvent(
1722
+ window2,
1723
+ "pointerup",
1724
+ (e) => {
1725
+ if (isPaused)
1726
+ return;
1727
+ if (e.button === 0) {
1728
+ const path = eventPath(e);
1729
+ e.composedPath = () => path;
1730
+ fallback = window2.setTimeout(() => listener(e), 50);
1731
+ }
1732
+ },
1733
+ { passive: true }
1734
+ )
1735
+ ].filter(Boolean);
1736
+ const stop = () => cleanups.forEach((fn) => fn());
1737
+ return { stop, pause, proceed };
1738
+ }
1739
+
1740
+ // src/utils/color/color.ts
1741
+ var r = Math.round;
1742
+ function toRGBA(color) {
1743
+ const l = color.length;
1744
+ const rgba = [];
1745
+ if (color.slice(0, 3).toLowerCase() === "rgb") {
1746
+ const d = color.match(/([\d|.%]{1,3})/g);
1747
+ rgba[0] = parseInt(d[0], 10);
1748
+ rgba[1] = parseInt(d[1], 10);
1749
+ rgba[2] = parseInt(d[2], 10);
1750
+ rgba[3] = d[3] ? d[3].indexOf("%") !== -1 ? parseInt(d[3], 10) / 100 : parseFloat(d[3]) : 1;
1751
+ } else {
1752
+ let d;
1753
+ if (l < 6)
1754
+ d = parseInt(
1755
+ String(color[1]) + color[1] + color[2] + color[2] + color[3] + color[3] + (l > 4 ? String(color[4]) + color[4] : ""),
1756
+ 16
1757
+ );
1758
+ else
1759
+ d = parseInt(color.slice(1), 16);
1760
+ rgba[0] = d >> 16 & 255;
1761
+ rgba[1] = d >> 8 & 255;
1762
+ rgba[2] = d & 255;
1763
+ rgba[3] = l === 9 || l === 5 ? r((d >> 24 & 255) / 255 * 1e4) / 1e4 : 1;
1764
+ }
1765
+ return rgba;
1766
+ }
1767
+ function colorBlend(color1, color2, p = 0.5, format = "hex") {
1768
+ color1 = color1.trim();
1769
+ color2 = color2.trim();
1770
+ const c1 = toRGBA(color1);
1771
+ const c2 = toRGBA(color2);
1772
+ const result = [
1773
+ r((1 - p) * c1[0] + p * c2[0]),
1774
+ r((1 - p) * c1[1] + p * c2[1]),
1775
+ r((1 - p) * c1[2] + p * c2[2]),
1776
+ (1 - p) * c1[3] + p * c2[3]
1777
+ ];
1778
+ if (format === "hex") {
1779
+ const hex = [
1780
+ result[0].toString(16),
1781
+ result[1].toString(16),
1782
+ result[2].toString(16),
1783
+ result[3] === 0 ? "00" : r(result[3] * 255).toString(16)
1784
+ ];
1785
+ return `#${hex[0]}${hex[1]}${hex[2]}${hex[3]}`;
1786
+ }
1787
+ return `rgb(${result[0]} ${result[1]} ${result[2]} / ${result[3]})`;
1788
+ }
1789
+
1790
+ // src/utils/download-file/download-file.ts
1791
+ function calcMimeByFileName(fileName) {
1792
+ const ext = fileName.split(".").pop();
1793
+ let mime = "";
1794
+ switch (ext) {
1795
+ case ".wps":
1796
+ mime = "application/kswps";
1797
+ break;
1798
+ case ".doc":
1799
+ mime = "application/msword";
1800
+ break;
1801
+ case ".docx":
1802
+ mime = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
1803
+ break;
1804
+ case ".txt":
1805
+ mime = "text/plain";
1806
+ break;
1807
+ case ".zip":
1808
+ mime = "application/zip";
1809
+ break;
1810
+ case ".png":
1811
+ mime = "image/png";
1812
+ break;
1813
+ case ".gif":
1814
+ mime = "image/gif";
1815
+ break;
1816
+ case ".jpeg":
1817
+ mime = "image/jpeg";
1818
+ break;
1819
+ case ".jpg":
1820
+ mime = "image/jpeg";
1821
+ break;
1822
+ case ".rtf":
1823
+ mime = "application/rtf";
1824
+ break;
1825
+ case ".avi":
1826
+ mime = "video/x-msvideo";
1827
+ break;
1828
+ case ".gz":
1829
+ mime = "application/x-gzip";
1830
+ break;
1831
+ case ".tar":
1832
+ mime = "application/x-tar";
1833
+ break;
1834
+ case ".xlsx":
1835
+ mime = "application/vnd.ms-excel";
1836
+ break;
1837
+ default:
1838
+ mime = "";
1839
+ }
1840
+ return mime;
1841
+ }
1842
+ function isImage(fileName) {
1843
+ const ext = fileName.split(".").pop();
1844
+ if (!ext) {
1845
+ return false;
1846
+ }
1847
+ const imageTypes = [".jpeg", "jpg", "gif", "png", "bmp", "svg"];
1848
+ return imageTypes.includes(ext);
1849
+ }
1850
+ function downloadFileFromBlob(file, fileName) {
1851
+ const filetype = calcMimeByFileName(fileName);
1852
+ const blob = new Blob([file], { type: filetype });
1853
+ const href = URL.createObjectURL(blob);
1854
+ const a = document.createElement("a");
1855
+ a.href = href;
1856
+ a.download = fileName;
1857
+ document.body.appendChild(a);
1858
+ a.click();
1859
+ document.body.removeChild(a);
1860
+ URL.revokeObjectURL(href);
1861
+ }
1862
+
1863
+ // src/utils/upload/select-file.ts
1864
+ import { merge as merge2 } from "lodash-es";
1865
+ function fileListToArr(fileList) {
1866
+ const files = [];
1867
+ for (let i = 0; i < fileList.length; i++) {
1868
+ files.push(fileList[i]);
1869
+ }
1870
+ return files;
1871
+ }
1872
+ function selectFile(_opts) {
1873
+ const opts = merge2(
1874
+ {
1875
+ multiple: true,
1876
+ accept: ""
1877
+ },
1878
+ _opts
1879
+ );
1880
+ const input = document.createElement("input");
1881
+ input.setAttribute("type", "file");
1882
+ input.setAttribute("multiple", `${opts.multiple}`);
1883
+ input.setAttribute("accept", opts.accept);
1884
+ input.onchange = (e) => {
1885
+ const inputEl = e.target;
1886
+ const files = inputEl.files ? fileListToArr(inputEl.files) : [];
1887
+ if (files.length === 0) {
1888
+ return;
1889
+ }
1890
+ opts.onSelected(files);
1891
+ inputEl.value = "";
1892
+ };
1893
+ document.body.appendChild(input);
1894
+ input.click();
1895
+ document.body.removeChild(input);
1896
+ }
1897
+
1898
+ // src/utils/upload/upload-file.ts
1899
+ import { cloneDeep, isFunction, merge as merge3, round, uniqueId } from "lodash-es";
1900
+ function uploadFile(_opts) {
1901
+ const opts = merge3(
1902
+ {
1903
+ multiple: true,
1904
+ accept: "",
1905
+ separate: true,
1906
+ beforeUpload: (_fileData, _files) => true,
1907
+ finish: (_resultFiles) => {
1908
+ },
1909
+ success: (_resultFiles, _res) => {
1910
+ },
1911
+ error: (_resultFiles, _error) => {
1912
+ },
1913
+ progress: (_files) => {
1914
+ }
1915
+ },
1916
+ _opts
1917
+ );
1918
+ const onUploadProgress = (event, files) => {
1919
+ files.forEach((file) => {
1920
+ file.percentage = round(event.progress * 100);
1921
+ });
1922
+ opts.progress(cloneDeep(files));
1923
+ };
1924
+ const uploadRequest = async (files, _onProgress) => {
1925
+ if (opts.request && isFunction(opts.request)) {
1926
+ return opts.request(files);
1927
+ }
1928
+ const data = new FormData();
1929
+ files.forEach((file) => {
1930
+ data.append("file", file);
1931
+ });
1932
+ throw new Error(`\u591A\u5E94\u7528\u6A21\u5F0F\u7B49\u5F85\u91CD\u65B0\u5B9E\u73B0\u8BF7\u6C42`);
1933
+ };
1934
+ const executeSingleUpload = async (files) => {
1935
+ const resultFiles = files.map((file) => {
1936
+ return {
1937
+ status: "uploading",
1938
+ name: file.name,
1939
+ uid: uniqueId(),
1940
+ percentage: 0
1941
+ };
1942
+ });
1943
+ const pass = opts.beforeUpload(files, resultFiles);
1944
+ if (!pass) {
1945
+ resultFiles.forEach((file) => {
1946
+ file.status = "cancel";
1947
+ });
1948
+ ibiz.log.debug("\u53D6\u6D88\u4E0A\u4F20", resultFiles);
1949
+ return resultFiles;
1950
+ }
1951
+ try {
1952
+ const res = await uploadRequest(files, (event) => {
1953
+ onUploadProgress(event, resultFiles);
1954
+ });
1955
+ resultFiles.forEach((file) => {
1956
+ file.status = "finished";
1957
+ });
1958
+ opts.success(resultFiles, res);
1959
+ resultFiles.forEach((file) => {
1960
+ file.response = res;
1961
+ });
1962
+ } catch (error) {
1963
+ resultFiles.forEach((file) => {
1964
+ file.status = "fail";
1965
+ });
1966
+ opts.error(resultFiles, error);
1967
+ resultFiles.forEach((file) => {
1968
+ file.error = error;
1969
+ });
1970
+ ibiz.log.error(error);
1971
+ ibiz.log.error(`${files.map((file) => file.name).join(",")}\u4E0A\u4F20\u5931\u8D25`);
1972
+ }
1973
+ return resultFiles;
1974
+ };
1975
+ const uploadFiles = async (files) => {
1976
+ const uploadSequence = opts.separate ? files.map((file) => [file]) : [files];
1977
+ const res = await Promise.allSettled(
1978
+ uploadSequence.map(async (sequence) => {
1979
+ return executeSingleUpload(sequence);
1980
+ })
1981
+ );
1982
+ const resultFiles = [];
1983
+ res.forEach((result) => {
1984
+ if (result.status === "fulfilled") {
1985
+ resultFiles.push(...result.value);
1986
+ }
1987
+ });
1988
+ opts.finish(resultFiles);
1989
+ };
1990
+ const select = () => {
1991
+ selectFile({
1992
+ accept: opts.accept,
1993
+ multiple: opts.multiple,
1994
+ onSelected: (files) => {
1995
+ uploadFiles(files);
1996
+ }
1997
+ });
1998
+ };
1999
+ select();
2000
+ }
2001
+
2002
+ // src/utils/sync/await-timeout.ts
2003
+ async function awaitTimeout(wait, fun, params) {
2004
+ await new Promise((resolve) => {
2005
+ setTimeout(() => {
2006
+ resolve(true);
2007
+ }, wait);
2008
+ });
2009
+ if (fun) {
2010
+ return fun(...params || []);
2011
+ }
2012
+ }
2013
+
2014
+ // src/utils/sync/count-latch.ts
2015
+ var CountLatch = class {
2016
+ constructor() {
2017
+ this.promise = null;
2018
+ this.resolve = null;
2019
+ /**
2020
+ * 计数,当前等待的异步逻辑个数
2021
+ *
2022
+ * @author lxm
2023
+ * @date 2022-11-24 19:11:59
2024
+ * @type {number}
2025
+ */
2026
+ this.count = 0;
2027
+ }
2028
+ /**
2029
+ * 开启promise
2030
+ *
2031
+ * @author lxm
2032
+ * @date 2022-11-24 19:11:32
2033
+ * @private
2034
+ */
2035
+ startPromise() {
2036
+ this.promise = new Promise((resolve) => {
2037
+ this.resolve = resolve;
2038
+ });
2039
+ }
2040
+ /**
2041
+ * 结束promise
2042
+ *
2043
+ * @author lxm
2044
+ * @date 2022-11-24 19:11:44
2045
+ * @private
2046
+ */
2047
+ endPromise() {
2048
+ if (this.resolve) {
2049
+ this.resolve();
2050
+ this.resolve = null;
2051
+ this.promise = null;
2052
+ }
2053
+ }
2054
+ /**
2055
+ * 上锁,计数加一
2056
+ * 第一次计数,开启异步
2057
+ *
2058
+ * @author lxm
2059
+ * @date 2022-11-24 19:11:27
2060
+ */
2061
+ lock() {
2062
+ this.count += 1;
2063
+ if (!this.promise) {
2064
+ this.startPromise();
2065
+ }
2066
+ }
2067
+ /**
2068
+ * 解锁,计数减一
2069
+ * 归零时结束异步
2070
+ *
2071
+ * @author lxm
2072
+ * @date 2022-11-24 19:11:47
2073
+ */
2074
+ unlock() {
2075
+ if (this.count < 1) {
2076
+ throw new RuntimeError("lock\u548Cunlock\u6B21\u6570\u4E0D\u5339\u914D\uFF01");
2077
+ }
2078
+ this.count -= 1;
2079
+ if (this.count === 0) {
2080
+ this.endPromise();
2081
+ }
2082
+ }
2083
+ /**
2084
+ * 等待,计数归零异步结束
2085
+ *
2086
+ * @author lxm
2087
+ * @date 2022-11-24 19:11:20
2088
+ */
2089
+ async await() {
2090
+ if (this.promise) {
2091
+ await this.promise;
2092
+ }
2093
+ }
2094
+ };
2095
+
2096
+ // src/utils/style/remote-style.ts
2097
+ async function setRemoteStyle(url) {
2098
+ try {
2099
+ const res = await ibiz.net.get(url);
2100
+ const styleDom = document.createElement("style");
2101
+ styleDom.setAttribute("title", "app-style-css");
2102
+ styleDom.innerText = res.data;
2103
+ document.head.appendChild(styleDom);
2104
+ } catch (error) {
2105
+ Logger.debug("\u52A0\u8F7D\u8FDC\u7A0B\u6837\u5F0F\u8868\u5931\u8D25", url);
2106
+ }
2107
+ }
2108
+
2109
+ // src/ibizsys.ts
2110
+ var IBizSys = class {
2111
+ constructor() {
2112
+ /**
2113
+ * 环境变量
2114
+ *
2115
+ * @author chitanda
2116
+ * @date 2022-07-19 18:07:04
2117
+ */
2118
+ this.env = Environment;
2119
+ /**
2120
+ * 日志对象
2121
+ *
2122
+ * @author chitanda
2123
+ * @date 2022-10-25 20:10:22
2124
+ */
2125
+ this.log = Logger;
2126
+ /**
2127
+ * 网络请求工具类
2128
+ *
2129
+ * @author chitanda
2130
+ * @date 2022-07-19 17:07:56
2131
+ * @type {Net}
2132
+ */
2133
+ this.net = new Net();
2134
+ /**
2135
+ * 指令集
2136
+ *
2137
+ * @author chitanda
2138
+ * @date 2022-07-20 10:07:33
2139
+ * @type {AuthService}
2140
+ */
2141
+ this.commands = new CommandController();
2142
+ }
2143
+ };
2144
+
2145
+ // src/factory-center.ts
2146
+ var FactoryCenter = class {
2147
+ };
2148
+
2149
+ // src/install.ts
2150
+ function install() {
2151
+ if (window.ibiz) {
2152
+ throw new Error("ibiz \u5DF2\u7ECF\u5B58\u5728, \u65E0\u9700\u91CD\u590D\u5B89\u88C5");
2153
+ }
2154
+ window.ibiz = new IBizSys();
2155
+ window.___fc = new FactoryCenter();
2156
+ }
2157
+ export {
2158
+ CommandController,
2159
+ CommandsRegistry,
2160
+ CoreConst,
2161
+ CoreInterceptor,
2162
+ CountLatch,
2163
+ Environment,
2164
+ FactoryCenter,
2165
+ HttpError,
2166
+ HttpResponse,
2167
+ HttpStatusMessageConst,
2168
+ IBizContext,
2169
+ IBizSys,
2170
+ Interceptor,
2171
+ LinkedList,
2172
+ Logger,
2173
+ LoginMode,
2174
+ MenuPermissionMode,
2175
+ ModelError,
2176
+ NOOP,
2177
+ Namespace,
2178
+ Net,
2179
+ RuntimeError,
2180
+ RuntimeModelError,
2181
+ StringUtil,
2182
+ UrlHelper,
2183
+ awaitTimeout,
2184
+ calcMimeByFileName,
2185
+ colorBlend,
2186
+ commands,
2187
+ debounce,
2188
+ debounceAndAsyncMerge,
2189
+ debounceAndMerge,
2190
+ downloadFileFromBlob,
2191
+ eventPath,
2192
+ fileListToArr,
2193
+ getToken,
2194
+ install,
2195
+ isEventInside,
2196
+ isImage,
2197
+ isOverlap,
2198
+ listenJSEvent,
2199
+ onClickOutside,
2200
+ plural,
2201
+ pluralLower,
2202
+ selectFile,
2203
+ setRemoteStyle,
2204
+ throttle,
2205
+ toDisposable,
2206
+ uploadFile
2207
+ };