@ibiz-template/core 0.0.1-alpha.6 → 0.0.1-beta.17

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 (165) hide show
  1. package/dist/system/index.system.js +1 -0
  2. package/out/command/command-register.d.ts +66 -0
  3. package/out/command/command-register.d.ts.map +1 -0
  4. package/out/command/command-register.js +113 -0
  5. package/out/command/command.d.ts +54 -0
  6. package/out/command/command.d.ts.map +1 -0
  7. package/out/command/command.js +71 -0
  8. package/out/command/index.d.ts +10 -0
  9. package/out/command/index.d.ts.map +1 -0
  10. package/out/command/index.js +9 -0
  11. package/out/command/interface/command/command-option.d.ts +23 -0
  12. package/out/command/interface/command/command-option.d.ts.map +1 -0
  13. package/out/command/interface/command/command-option.js +1 -0
  14. package/out/command/interface/command/command.d.ts +74 -0
  15. package/out/command/interface/command/command.d.ts.map +1 -0
  16. package/out/command/interface/command/command.js +1 -0
  17. package/out/command/interface/disposable/disposable.d.ts +4 -0
  18. package/out/command/interface/disposable/disposable.d.ts.map +1 -0
  19. package/out/command/interface/disposable/disposable.js +1 -0
  20. package/out/command/interface/index.d.ts +4 -0
  21. package/out/command/interface/index.d.ts.map +1 -0
  22. package/out/command/interface/index.js +1 -0
  23. package/out/command/utils/index.d.ts +3 -0
  24. package/out/command/utils/index.d.ts.map +1 -0
  25. package/out/command/utils/index.js +2 -0
  26. package/out/command/utils/linked-list.d.ts +16 -0
  27. package/out/command/utils/linked-list.d.ts.map +1 -0
  28. package/out/command/utils/linked-list.js +120 -0
  29. package/out/command/utils/util.d.ts +27 -0
  30. package/out/command/utils/util.d.ts.map +1 -0
  31. package/out/command/utils/util.js +77 -0
  32. package/out/constant/index.d.ts +3 -0
  33. package/out/constant/index.d.ts.map +1 -1
  34. package/out/constant/index.js +3 -0
  35. package/out/constant/login-mode/login-mode.d.ts +23 -0
  36. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  37. package/out/constant/login-mode/login-mode.js +24 -0
  38. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  39. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  40. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  41. package/out/constant/util/util.d.ts +5 -0
  42. package/out/constant/util/util.d.ts.map +1 -0
  43. package/out/constant/util/util.js +5 -0
  44. package/out/context/index.d.ts +19 -32
  45. package/out/context/index.d.ts.map +1 -1
  46. package/out/context/index.js +52 -60
  47. package/out/environment/environment.d.ts.map +1 -1
  48. package/out/environment/environment.js +11 -2
  49. package/out/error/http-error/http-error.d.ts.map +1 -1
  50. package/out/error/http-error/http-error.js +0 -4
  51. package/out/factory-center.d.ts +11 -0
  52. package/out/factory-center.d.ts.map +1 -0
  53. package/out/factory-center.js +10 -0
  54. package/out/ibizsys.d.ts +17 -1
  55. package/out/ibizsys.d.ts.map +1 -1
  56. package/out/ibizsys.js +17 -1
  57. package/out/index.d.ts +3 -1
  58. package/out/index.d.ts.map +1 -1
  59. package/out/index.js +3 -1
  60. package/out/install.d.ts.map +1 -1
  61. package/out/install.js +4 -2
  62. package/out/interface/click-outside/click-outside.d.ts +70 -0
  63. package/out/interface/click-outside/click-outside.d.ts.map +1 -0
  64. package/out/interface/click-outside/click-outside.js +1 -0
  65. package/out/interface/i-environment/i-environment.d.ts +72 -4
  66. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  67. package/out/interface/index.d.ts +1 -0
  68. package/out/interface/index.d.ts.map +1 -1
  69. package/out/interface/index.js +1 -1
  70. package/out/types.d.ts +10 -0
  71. package/out/types.d.ts.map +1 -1
  72. package/out/utils/click-outside/click-outside.d.ts +14 -0
  73. package/out/utils/click-outside/click-outside.d.ts.map +1 -0
  74. package/out/utils/click-outside/click-outside.js +85 -0
  75. package/out/utils/color/color.d.ts +13 -0
  76. package/out/utils/color/color.d.ts.map +1 -0
  77. package/out/utils/color/color.js +76 -0
  78. package/out/utils/download-file/download-file.d.ts +31 -0
  79. package/out/utils/download-file/download-file.d.ts.map +1 -0
  80. package/out/utils/download-file/download-file.js +107 -0
  81. package/out/utils/event/event.d.ts +34 -0
  82. package/out/utils/event/event.d.ts.map +1 -0
  83. package/out/utils/event/event.js +60 -0
  84. package/out/utils/index.d.ts +10 -1
  85. package/out/utils/index.d.ts.map +1 -1
  86. package/out/utils/index.js +10 -1
  87. package/out/utils/interceptor/core-interceptor.d.ts +15 -0
  88. package/out/utils/interceptor/core-interceptor.d.ts.map +1 -0
  89. package/out/utils/interceptor/core-interceptor.js +30 -0
  90. package/out/utils/interceptor/index.d.ts +3 -0
  91. package/out/utils/interceptor/index.d.ts.map +1 -0
  92. package/out/utils/interceptor/index.js +2 -0
  93. package/out/utils/interceptor/interceptor.d.ts +74 -3
  94. package/out/utils/interceptor/interceptor.d.ts.map +1 -1
  95. package/out/utils/interceptor/interceptor.js +73 -22
  96. package/out/utils/logger/logger.d.ts +3 -0
  97. package/out/utils/logger/logger.d.ts.map +1 -0
  98. package/out/utils/logger/logger.js +2 -0
  99. package/out/utils/net/http-response.d.ts +4 -9
  100. package/out/utils/net/http-response.d.ts.map +1 -1
  101. package/out/utils/net/http-response.js +0 -7
  102. package/out/utils/net/net.d.ts +82 -31
  103. package/out/utils/net/net.d.ts.map +1 -1
  104. package/out/utils/net/net.js +109 -40
  105. package/out/utils/sync/count-latch.d.ts +60 -0
  106. package/out/utils/sync/count-latch.d.ts.map +1 -0
  107. package/out/utils/sync/count-latch.js +93 -0
  108. package/out/utils/sync/index.d.ts +2 -0
  109. package/out/utils/sync/index.d.ts.map +1 -0
  110. package/out/utils/sync/index.js +1 -0
  111. package/out/utils/upload/select-file.d.ts +53 -0
  112. package/out/utils/upload/select-file.d.ts.map +1 -0
  113. package/out/utils/upload/select-file.js +47 -0
  114. package/out/utils/upload/upload-file.d.ts +46 -0
  115. package/out/utils/upload/upload-file.d.ts.map +1 -0
  116. package/out/utils/upload/upload-file.js +150 -0
  117. package/out/utils/url-helper/url-helper.d.ts +51 -0
  118. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  119. package/out/utils/url-helper/url-helper.js +59 -0
  120. package/out/utils/util/util.d.ts +20 -4
  121. package/out/utils/util/util.d.ts.map +1 -1
  122. package/out/utils/util/util.js +59 -5
  123. package/package.json +19 -9
  124. package/src/command/command-register.ts +135 -0
  125. package/src/command/command.ts +79 -0
  126. package/src/command/index.ts +11 -0
  127. package/src/command/interface/command/command-option.ts +22 -0
  128. package/src/command/interface/command/command.ts +86 -0
  129. package/src/command/interface/disposable/disposable.ts +3 -0
  130. package/src/command/interface/index.ts +9 -0
  131. package/src/command/utils/index.ts +2 -0
  132. package/src/command/utils/linked-list.ts +136 -0
  133. package/src/command/utils/util.ts +95 -0
  134. package/src/constant/index.ts +3 -0
  135. package/src/constant/login-mode/login-mode.ts +23 -0
  136. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  137. package/src/constant/util/util.ts +5 -0
  138. package/src/context/index.ts +69 -59
  139. package/src/environment/environment.ts +11 -2
  140. package/src/error/http-error/http-error.ts +0 -4
  141. package/src/factory-center.ts +9 -0
  142. package/src/ibizsys.ts +19 -1
  143. package/src/index.ts +3 -1
  144. package/src/install.ts +4 -2
  145. package/src/interface/click-outside/click-outside.ts +71 -0
  146. package/src/interface/i-environment/i-environment.ts +81 -4
  147. package/src/interface/index.ts +1 -0
  148. package/src/types.ts +10 -0
  149. package/src/utils/click-outside/click-outside.ts +110 -0
  150. package/src/utils/color/color.ts +84 -0
  151. package/src/utils/download-file/download-file.ts +109 -0
  152. package/src/utils/event/event.ts +77 -0
  153. package/src/utils/index.ts +10 -1
  154. package/src/utils/interceptor/core-interceptor.ts +35 -0
  155. package/src/utils/interceptor/index.ts +2 -0
  156. package/src/utils/interceptor/interceptor.ts +109 -22
  157. package/src/utils/logger/logger.ts +3 -0
  158. package/src/utils/net/http-response.ts +6 -9
  159. package/src/utils/net/net.ts +144 -51
  160. package/src/utils/sync/count-latch.ts +99 -0
  161. package/src/utils/sync/index.ts +1 -0
  162. package/src/utils/upload/select-file.ts +86 -0
  163. package/src/utils/upload/upload-file.ts +206 -0
  164. package/src/utils/url-helper/url-helper.ts +62 -0
  165. package/src/utils/util/util.ts +72 -14
@@ -0,0 +1,135 @@
1
+ import {
2
+ ICommand,
3
+ ICommandHandler,
4
+ ICommandOption,
5
+ ICommandRegistry,
6
+ ICommandsMap,
7
+ IDisposable,
8
+ } from './interface';
9
+ import { LinkedList, toDisposable } from './utils';
10
+
11
+ /**
12
+ * 命令注册中心
13
+ *
14
+ * @author chitanda
15
+ * @date 2022-06-27 13:06:50
16
+ * @export
17
+ * @class CommandRegisterService
18
+ * @implements {ICommandRegistry}
19
+ */
20
+ export class CommandsRegistry implements ICommandRegistry {
21
+ /**
22
+ * 已经注册的所有指令
23
+ *
24
+ * @author chitanda
25
+ * @date 2022-07-21 15:07:47
26
+ * @private
27
+ */
28
+ private readonly commands = new Map<string, LinkedList<ICommand>>();
29
+
30
+ /**
31
+ * 注册指令
32
+ *
33
+ * @author chitanda
34
+ * @date 2022-06-27 13:06:31
35
+ * @param {(string | ICommand)} idOrCommand
36
+ * @param {ICommandHandler} [handler]
37
+ * @return {*} {IDisposable}
38
+ */
39
+ registerCommand(
40
+ idOrCommand: string | ICommand,
41
+ handler?: ICommandHandler,
42
+ opts?: ICommandOption,
43
+ ): IDisposable {
44
+ if (!idOrCommand) {
45
+ throw new Error(`invalid command`);
46
+ }
47
+
48
+ if (typeof idOrCommand === 'string') {
49
+ if (!handler) {
50
+ throw new Error(`invalid command`);
51
+ }
52
+ return this.registerCommand({ id: idOrCommand, handler, opts });
53
+ }
54
+
55
+ const { id } = idOrCommand;
56
+
57
+ let commands = this.commands.get(id);
58
+ if (!commands) {
59
+ commands = new LinkedList<ICommand>();
60
+ this.commands.set(id, commands);
61
+ }
62
+
63
+ const removeFn = commands.unshift(idOrCommand);
64
+
65
+ const ret = toDisposable(() => {
66
+ removeFn();
67
+ const command = this.commands.get(id);
68
+ if (command?.isEmpty()) {
69
+ this.commands.delete(id);
70
+ }
71
+ });
72
+
73
+ return ret;
74
+ }
75
+
76
+ /**
77
+ * 指令是否已经注册
78
+ *
79
+ * @author chitanda
80
+ * @date 2022-07-21 15:07:58
81
+ * @param {string} id
82
+ * @return {*} {boolean}
83
+ */
84
+ hasCommand(id: string): boolean {
85
+ return this.commands.has(id);
86
+ }
87
+
88
+ /**
89
+ * 查找指令
90
+ *
91
+ * @author chitanda
92
+ * @date 2022-07-21 16:07:12
93
+ * @param {string} id
94
+ * @return {*} {(ICommand | undefined)}
95
+ */
96
+ getCommand(id: string): ICommand | undefined {
97
+ const list = this.commands.get(id);
98
+ if (!list || list.isEmpty()) {
99
+ return undefined;
100
+ }
101
+ return list[Symbol.iterator]().next().value;
102
+ }
103
+
104
+ /**
105
+ * 获取所有指令
106
+ *
107
+ * @author chitanda
108
+ * @date 2022-07-21 16:07:20
109
+ * @return {*} {ICommandsMap}
110
+ */
111
+ getCommands(): ICommandsMap {
112
+ const result = new Map<string, ICommand>();
113
+ const keys = this.commands.keys();
114
+ for (const key of keys) {
115
+ const command = this.getCommand(key);
116
+ if (command) {
117
+ result.set(key, command);
118
+ }
119
+ }
120
+ return result;
121
+ }
122
+
123
+ /**
124
+ * 获取指令配置参数
125
+ *
126
+ * @author chitanda
127
+ * @date 2022-07-21 16:07:27
128
+ * @param {string} id
129
+ * @return {*} {(ICommandOption | undefined)}
130
+ */
131
+ getCommandOpt(id: string): ICommandOption | undefined {
132
+ const cmd = this.getCommand(id);
133
+ return cmd?.opts;
134
+ }
135
+ }
@@ -0,0 +1,79 @@
1
+ import { ICommandHandler, ICommandOption, IDisposable } from './interface';
2
+ import { CommandsRegistry } from './command-register';
3
+
4
+ /**
5
+ * 指令控制器
6
+ *
7
+ * @author chitanda
8
+ * @date 2022-06-28 19:06:51
9
+ * @export
10
+ * @class CommandController
11
+ */
12
+ export class CommandController {
13
+ private commandRegister = new CommandsRegistry();
14
+
15
+ /**
16
+ * 注册指令
17
+ *
18
+ * @author chitanda
19
+ * @date 2022-06-28 19:06:45
20
+ * @param {string} id
21
+ * @param {ICommandHandler} handler
22
+ * @param {ICommandOption} [opts]
23
+ * @return {*} {IDisposable}
24
+ */
25
+ register(
26
+ id: string,
27
+ handler: ICommandHandler,
28
+ opts?: ICommandOption,
29
+ ): IDisposable {
30
+ return this.commandRegister.registerCommand(id, handler, opts);
31
+ }
32
+
33
+ /**
34
+ * 执行指令
35
+ *
36
+ * @author chitanda
37
+ * @date 2022-06-28 19:06:38
38
+ * @template T
39
+ * @param {string} id
40
+ * @param {...unknown[]} args
41
+ * @return {*} {Promise<T>}
42
+ */
43
+ async execute<T = undefined>(id: string, ...args: unknown[]): Promise<T> {
44
+ const command = this.commandRegister.getCommand(id);
45
+ if (command) {
46
+ return command.handler(...args) as T | Promise<T>;
47
+ }
48
+ throw new Error(`未注册指令: ${id},请先注册指令`);
49
+ }
50
+
51
+ /**
52
+ * 判断指令是否存在,可直接抛出异常
53
+ *
54
+ * @author chitanda
55
+ * @date 2022-06-28 19:06:11
56
+ * @param {string} id
57
+ * @param {boolean} [err]
58
+ * @return {*} {boolean}
59
+ */
60
+ hasCommand(id: string, err?: boolean): boolean {
61
+ const bol = !!this.commandRegister.hasCommand(id);
62
+ if (err === true && bol === true) {
63
+ throw new Error(`未注册指令: ${id},请先注册指令`);
64
+ }
65
+ return bol;
66
+ }
67
+
68
+ /**
69
+ * 获取指令配置参数
70
+ *
71
+ * @author chitanda
72
+ * @date 2022-07-21 17:07:11
73
+ * @param {string} id
74
+ * @return {*} {(ICommandOption | undefined)}
75
+ */
76
+ getCommandOpts(id: string): ICommandOption | undefined {
77
+ return this.commandRegister.getCommandOpt(id);
78
+ }
79
+ }
@@ -0,0 +1,11 @@
1
+ import { CommandController } from './command';
2
+
3
+ export * from './interface';
4
+ export * from './utils';
5
+ export { CommandsRegistry } from './command-register';
6
+ export { CommandController } from './command';
7
+
8
+ /**
9
+ * 命令控制器
10
+ */
11
+ export const commands = new CommandController();
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 指令参数, 主要用于在指令呈现时的展示参数
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-06-28 17:06:47
6
+ * @export
7
+ * @interface ICommandOption
8
+ */
9
+ export interface ICommandOption {
10
+ readonly id: string;
11
+ readonly title: string;
12
+ readonly tooltip?: string;
13
+ readonly description?: string;
14
+ /**
15
+ * 只支持 svg 图标
16
+ *
17
+ * @author chitanda
18
+ * @date 2022-06-29 14:06:42
19
+ * @type {string}
20
+ */
21
+ readonly icon?: string;
22
+ }
@@ -0,0 +1,86 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { IDisposable } from '../disposable/disposable';
3
+ import { ICommandOption } from './command-option';
4
+
5
+ /**
6
+ * 注册指令
7
+ *
8
+ * @author chitanda
9
+ * @date 2022-06-27 13:06:25
10
+ * @export
11
+ * @interface ICommand
12
+ */
13
+ export interface ICommand {
14
+ id: string;
15
+ handler: ICommandHandler;
16
+ opts?: ICommandOption;
17
+ }
18
+
19
+ /**
20
+ * 触发指令声明
21
+ *
22
+ * @author chitanda
23
+ * @date 2022-06-28 17:06:10
24
+ * @export
25
+ * @interface Command
26
+ */
27
+ export interface Command {
28
+ /**
29
+ * Title of the command, like `save`.
30
+ */
31
+ title: string;
32
+
33
+ /**
34
+ * The identifier of the actual command handler.
35
+ * @see {@link commands.registerCommand}
36
+ */
37
+ command: string;
38
+
39
+ /**
40
+ * A tooltip for the command, when represented in the UI.
41
+ */
42
+ tooltip?: string;
43
+
44
+ /**
45
+ * Arguments that the command handler should be
46
+ * invoked with.
47
+ */
48
+ arguments?: any[];
49
+ }
50
+
51
+ /**
52
+ * 指令处理回调
53
+ *
54
+ * @author chitanda
55
+ * @date 2022-06-27 13:06:33
56
+ * @export
57
+ * @interface ICommandHandler
58
+ */
59
+ export interface ICommandHandler {
60
+ (...args: any[]): unknown | Promise<unknown>;
61
+ }
62
+
63
+ /**
64
+ * 指令控制器集
65
+ */
66
+ export type ICommandsMap = Map<string, ICommand>;
67
+
68
+ /**
69
+ * 注册服务
70
+ *
71
+ * @author chitanda
72
+ * @date 2022-06-27 13:06:16
73
+ * @export
74
+ * @interface ICommandRegistry
75
+ */
76
+ export interface ICommandRegistry {
77
+ registerCommand(
78
+ id: string,
79
+ command: ICommandHandler,
80
+ opts: ICommandOption,
81
+ ): IDisposable;
82
+ registerCommand(id: string, command: ICommandHandler): IDisposable;
83
+ registerCommand(command: ICommand): IDisposable;
84
+ getCommand(id: string): ICommand | undefined;
85
+ getCommands(): ICommandsMap;
86
+ }
@@ -0,0 +1,3 @@
1
+ export interface IDisposable {
2
+ dispose(): void;
3
+ }
@@ -0,0 +1,9 @@
1
+ export {
2
+ ICommand,
3
+ Command,
4
+ ICommandHandler,
5
+ ICommandsMap,
6
+ ICommandRegistry,
7
+ } from './command/command';
8
+ export { ICommandOption } from './command/command-option';
9
+ export { IDisposable } from './disposable/disposable';
@@ -0,0 +1,2 @@
1
+ export { LinkedList } from './linked-list';
2
+ export { toDisposable, debounce, throttle } from './util';
@@ -0,0 +1,136 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ /* eslint-disable no-underscore-dangle */
3
+ /* eslint-disable max-classes-per-file */
4
+ class Node<E> {
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ static readonly Undefined = new Node<any>(undefined);
7
+
8
+ element: E;
9
+
10
+ next: Node<E>;
11
+
12
+ prev: Node<E>;
13
+
14
+ constructor(element: E) {
15
+ this.element = element;
16
+ this.next = Node.Undefined;
17
+ this.prev = Node.Undefined;
18
+ }
19
+ }
20
+
21
+ export class LinkedList<E> {
22
+ private _first: Node<E> = Node.Undefined;
23
+
24
+ private _last: Node<E> = Node.Undefined;
25
+
26
+ private _size: number = 0;
27
+
28
+ get size(): number {
29
+ return this._size;
30
+ }
31
+
32
+ isEmpty(): boolean {
33
+ return this._first === Node.Undefined;
34
+ }
35
+
36
+ clear(): void {
37
+ let node = this._first;
38
+ while (node !== Node.Undefined) {
39
+ const { next } = node;
40
+ node.prev = Node.Undefined;
41
+ node.next = Node.Undefined;
42
+ node = next;
43
+ }
44
+
45
+ this._first = Node.Undefined;
46
+ this._last = Node.Undefined;
47
+ this._size = 0;
48
+ }
49
+
50
+ unshift(element: E): () => void {
51
+ return this._insert(element, false);
52
+ }
53
+
54
+ push(element: E): () => void {
55
+ return this._insert(element, true);
56
+ }
57
+
58
+ private _insert(element: E, atTheEnd: boolean): () => void {
59
+ const newNode = new Node(element);
60
+ if (this._first === Node.Undefined) {
61
+ this._first = newNode;
62
+ this._last = newNode;
63
+ } else if (atTheEnd) {
64
+ // push
65
+ const oldLast = this._last!;
66
+ this._last = newNode;
67
+ newNode.prev = oldLast;
68
+ oldLast.next = newNode;
69
+ } else {
70
+ // unshift
71
+ const oldFirst = this._first;
72
+ this._first = newNode;
73
+ newNode.next = oldFirst;
74
+ oldFirst.prev = newNode;
75
+ }
76
+ this._size += 1;
77
+
78
+ let didRemove = false;
79
+ return () => {
80
+ if (!didRemove) {
81
+ didRemove = true;
82
+ this._remove(newNode);
83
+ }
84
+ };
85
+ }
86
+
87
+ shift(): E | undefined {
88
+ if (this._first === Node.Undefined) {
89
+ return undefined;
90
+ }
91
+ const res = this._first.element;
92
+ this._remove(this._first);
93
+ return res;
94
+ }
95
+
96
+ pop(): E | undefined {
97
+ if (this._last === Node.Undefined) {
98
+ return undefined;
99
+ }
100
+ const res = this._last.element;
101
+ this._remove(this._last);
102
+ return res;
103
+ }
104
+
105
+ private _remove(node: Node<E>): void {
106
+ if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
107
+ // middle
108
+ const anchor = node.prev;
109
+ anchor.next = node.next;
110
+ node.next.prev = anchor;
111
+ } else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
112
+ // only node
113
+ this._first = Node.Undefined;
114
+ this._last = Node.Undefined;
115
+ } else if (node.next === Node.Undefined) {
116
+ // last
117
+ this._last = this._last!.prev!;
118
+ this._last.next = Node.Undefined;
119
+ } else if (node.prev === Node.Undefined) {
120
+ // first
121
+ this._first = this._first!.next!;
122
+ this._first.prev = Node.Undefined;
123
+ }
124
+
125
+ // done
126
+ this._size -= 1;
127
+ }
128
+
129
+ *[Symbol.iterator](): Iterator<E> {
130
+ let node = this._first;
131
+ while (node !== Node.Undefined) {
132
+ yield node.element;
133
+ node = node.next;
134
+ }
135
+ }
136
+ }
@@ -0,0 +1,95 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable prefer-rest-params */
3
+ /* eslint-disable no-underscore-dangle */
4
+ import { IDisposable } from '../interface';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/ban-types
7
+ export function once<T extends Function>(this: unknown, fn: T): T {
8
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
9
+ const _this = this;
10
+ let didCall = false;
11
+ let result: unknown;
12
+
13
+ return function () {
14
+ if (didCall) {
15
+ return result;
16
+ }
17
+
18
+ didCall = true;
19
+ result = fn.apply(_this, arguments);
20
+
21
+ return result;
22
+ } as unknown as T;
23
+ }
24
+
25
+ export function toDisposable(fn: () => void): IDisposable {
26
+ const self = {
27
+ dispose: once(() => {
28
+ fn();
29
+ }),
30
+ };
31
+ return self;
32
+ }
33
+
34
+ /**
35
+ * 函数防抖---“立即执行版本” 和 “非立即执行版本” 的组合版本
36
+ *
37
+ * @author chitanda
38
+ * @date 2022-06-29 19:06:15
39
+ * @export
40
+ * @param {((...args: unknown[]) => void | Promise<void>)} func 处理函数
41
+ * @param {number} wait 延迟执行时间(毫秒)
42
+ * @param {boolean} [immediate] 是否立即执行
43
+ * @return {*} {(...args: unknown[]) => void}
44
+ */
45
+ export function debounce(
46
+ func: (...args: unknown[]) => void | Promise<void>,
47
+ wait: number,
48
+ immediate?: boolean,
49
+ ): (...args: unknown[]) => void {
50
+ let timer: unknown;
51
+
52
+ return function (this: unknown, ...args: unknown[]): void {
53
+ if (timer) {
54
+ clearTimeout(timer as number);
55
+ }
56
+ if (immediate) {
57
+ const callNow = !timer;
58
+ timer = setTimeout(() => {
59
+ timer = null;
60
+ }, wait);
61
+ if (callNow) {
62
+ func.apply(this, args);
63
+ }
64
+ } else {
65
+ timer = setTimeout(() => {
66
+ func.apply(this, args);
67
+ }, wait);
68
+ }
69
+ };
70
+ }
71
+
72
+ /**
73
+ * 节流函数
74
+ *
75
+ * @author chitanda
76
+ * @date 2022-06-29 20:06:38
77
+ * @export
78
+ * @param {((...args: unknown[]) => void | Promise<void>)} fn
79
+ * @param {number} wait
80
+ * @return {*} {(...args: unknown[]) => void}
81
+ */
82
+ export function throttle(
83
+ fn: (...args: unknown[]) => void | Promise<void>,
84
+ wait: number,
85
+ ): (...args: unknown[]) => void {
86
+ let timer: unknown = null;
87
+ return function (this: unknown, ...args: unknown[]): void {
88
+ if (!timer) {
89
+ timer = setTimeout(() => {
90
+ fn.apply(this, args);
91
+ timer = null;
92
+ }, wait);
93
+ }
94
+ };
95
+ }
@@ -1,2 +1,5 @@
1
1
  export { CoreConst } from './core/core';
2
+ export * from './util/util';
2
3
  export { HttpStatusMessageConst } from './http-status-message/http-status-message';
4
+ export { LoginMode } from './login-mode/login-mode';
5
+ export { MenuPermissionMode } from './menu-permission-mode/menu-permission-mode';
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 登录模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum LoginMode {
11
+ /**
12
+ * 默认标准登录
13
+ */
14
+ DEFAULT = 'DEFAULT',
15
+ /**
16
+ * 自定义登录
17
+ */
18
+ CUSTOM = 'CUSTOM',
19
+ /**
20
+ * 中央认证登录
21
+ */
22
+ CAS = 'CAS',
23
+ }
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 菜单权限校验模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum MenuPermissionMode {
11
+ /**
12
+ * 混合模式(默认)
13
+ */
14
+ MIXIN = 'MIXIN',
15
+ /**
16
+ * 统一资源模式
17
+ */
18
+ RESOURCE = 'RESOURCE',
19
+ /**
20
+ * RT模式
21
+ */
22
+ RT = 'RT',
23
+ }
@@ -0,0 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ /**
3
+ * 无操作函数
4
+ */
5
+ export const NOOP = () => {};