@ibiz-template/core 0.6.0-alpha.4 → 0.6.1-dev.1

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 (85) hide show
  1. package/package.json +3 -4
  2. package/src/command/command-register.ts +0 -135
  3. package/src/command/command.ts +0 -79
  4. package/src/command/index.ts +0 -11
  5. package/src/command/interface/command/command-option.ts +0 -22
  6. package/src/command/interface/command/command.ts +0 -86
  7. package/src/command/interface/disposable/disposable.ts +0 -3
  8. package/src/command/interface/index.ts +0 -9
  9. package/src/command/utils/index.ts +0 -2
  10. package/src/command/utils/linked-list.ts +0 -136
  11. package/src/command/utils/util.ts +0 -95
  12. package/src/constant/core/core.ts +0 -63
  13. package/src/constant/http-status-message/http-status-message.ts +0 -20
  14. package/src/constant/index.ts +0 -5
  15. package/src/constant/login-mode/login-mode.ts +0 -23
  16. package/src/constant/menu-permission-mode/menu-permission-mode.ts +0 -23
  17. package/src/constant/util/util.ts +0 -5
  18. package/src/context/index.ts +0 -231
  19. package/src/environment/environment.ts +0 -39
  20. package/src/error/http-error/http-error.ts +0 -45
  21. package/src/error/index.ts +0 -5
  22. package/src/error/model-error/model-error.ts +0 -26
  23. package/src/error/notice-error/notice-error.ts +0 -19
  24. package/src/error/runtime-error/runtime-error.ts +0 -16
  25. package/src/error/runtime-model-error/runtime-model-error.ts +0 -27
  26. package/src/ibizsys.ts +0 -78
  27. package/src/index.ts +0 -14
  28. package/src/install.ts +0 -15
  29. package/src/interface/click-outside/click-outside.ts +0 -71
  30. package/src/interface/i-18n/i-18n.ts +0 -68
  31. package/src/interface/i-chat-message/i-chat-message.ts +0 -83
  32. package/src/interface/i-devtool-config/i-devtool-config.ts +0 -16
  33. package/src/interface/i-environment/i-environment.ts +0 -289
  34. package/src/interface/i-internal-message/i-internal-message.ts +0 -151
  35. package/src/interface/i-mark-open-data/i-mark-open-data.ts +0 -39
  36. package/src/interface/i-portal-async-action/i-portal-async-action.ts +0 -177
  37. package/src/interface/i-portal-message/i-portal-message.ts +0 -84
  38. package/src/interface/index.ts +0 -14
  39. package/src/interface/org-data/org-data.ts +0 -42
  40. package/src/params/params.ts +0 -134
  41. package/src/types.ts +0 -110
  42. package/src/utils/bit-mask/bit-mask.ts +0 -85
  43. package/src/utils/click-outside/click-outside.ts +0 -110
  44. package/src/utils/clone/clone.ts +0 -43
  45. package/src/utils/color/color.ts +0 -84
  46. package/src/utils/data-type/data-types.ts +0 -99
  47. package/src/utils/download-file/download-file.ts +0 -109
  48. package/src/utils/event/event.ts +0 -77
  49. package/src/utils/history-list/history-item.ts +0 -45
  50. package/src/utils/history-list/history-list.ts +0 -151
  51. package/src/utils/index.ts +0 -24
  52. package/src/utils/interceptor/core-interceptor.ts +0 -40
  53. package/src/utils/interceptor/index.ts +0 -2
  54. package/src/utils/interceptor/interceptor.ts +0 -126
  55. package/src/utils/logger/logger.ts +0 -10
  56. package/src/utils/message-center/base/message-all.ts +0 -12
  57. package/src/utils/message-center/base/message-base.ts +0 -86
  58. package/src/utils/message-center/command/async-action/command-async-action.ts +0 -24
  59. package/src/utils/message-center/command/change/command-change.ts +0 -12
  60. package/src/utils/message-center/command/command-base/command-base.ts +0 -30
  61. package/src/utils/message-center/command/create/command-create.ts +0 -24
  62. package/src/utils/message-center/command/internal-message/command-internal-message.ts +0 -24
  63. package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +0 -24
  64. package/src/utils/message-center/command/message-command.ts +0 -158
  65. package/src/utils/message-center/command/remove/command-remove.ts +0 -24
  66. package/src/utils/message-center/command/update/command-update.ts +0 -24
  67. package/src/utils/message-center/console/message-console.ts +0 -31
  68. package/src/utils/message-center/index.ts +0 -1
  69. package/src/utils/message-center/interface/i-app-data-entity.ts +0 -19
  70. package/src/utils/message-center/interface/index.ts +0 -1
  71. package/src/utils/message-center/message-center.ts +0 -82
  72. package/src/utils/namespace/namespace.ts +0 -247
  73. package/src/utils/net/http-response.ts +0 -106
  74. package/src/utils/net/net.ts +0 -469
  75. package/src/utils/recursive/find-recursive-child.ts +0 -133
  76. package/src/utils/string-util/string-util.ts +0 -60
  77. package/src/utils/style/remote-style.ts +0 -20
  78. package/src/utils/sync/await-timeout.ts +0 -27
  79. package/src/utils/sync/count-latch.ts +0 -95
  80. package/src/utils/sync/index.ts +0 -2
  81. package/src/utils/types/types.ts +0 -22
  82. package/src/utils/upload/select-file.ts +0 -86
  83. package/src/utils/upload/upload-file.ts +0 -208
  84. package/src/utils/url-helper/url-helper.ts +0 -63
  85. package/src/utils/util/util.ts +0 -376
@@ -1,95 +0,0 @@
1
- import { RuntimeError } from '../../error';
2
-
3
- /**
4
- * 计数插销工具类
5
- *
6
- * @author lxm
7
- * @date 2022-11-24 19:11:49
8
- * @export
9
- * @class CountLatch
10
- */
11
- export class CountLatch {
12
- private promise: Promise<void> | null = null;
13
-
14
- private resolve: ((value: void) => void) | null = null;
15
-
16
- /**
17
- * 计数,当前等待的异步逻辑个数
18
- *
19
- * @author lxm
20
- * @date 2022-11-24 19:11:59
21
- * @type {number}
22
- */
23
- count: number = 0;
24
-
25
- /**
26
- * 开启promise
27
- *
28
- * @author lxm
29
- * @date 2022-11-24 19:11:32
30
- * @private
31
- */
32
- private startPromise(): void {
33
- this.promise = new Promise(resolve => {
34
- this.resolve = resolve;
35
- });
36
- }
37
-
38
- /**
39
- * 结束promise
40
- *
41
- * @author lxm
42
- * @date 2022-11-24 19:11:44
43
- * @private
44
- */
45
- private endPromise(): void {
46
- if (this.resolve) {
47
- this.resolve();
48
- this.resolve = null;
49
- this.promise = null;
50
- }
51
- }
52
-
53
- /**
54
- * 上锁,计数加一
55
- * 第一次计数,开启异步
56
- *
57
- * @author lxm
58
- * @date 2022-11-24 19:11:27
59
- */
60
- lock(): void {
61
- this.count += 1;
62
- if (!this.promise) {
63
- this.startPromise();
64
- }
65
- }
66
-
67
- /**
68
- * 解锁,计数减一
69
- * 归零时结束异步
70
- *
71
- * @author lxm
72
- * @date 2022-11-24 19:11:47
73
- */
74
- unlock(): void {
75
- if (this.count < 1) {
76
- throw new RuntimeError('lock和unlock次数不匹配!');
77
- }
78
- this.count -= 1;
79
- if (this.count === 0) {
80
- this.endPromise();
81
- }
82
- }
83
-
84
- /**
85
- * 等待,计数归零异步结束
86
- *
87
- * @author lxm
88
- * @date 2022-11-24 19:11:20
89
- */
90
- async await(): Promise<void> {
91
- if (this.promise) {
92
- await this.promise;
93
- }
94
- }
95
- }
@@ -1,2 +0,0 @@
1
- export { awaitTimeout } from './await-timeout';
2
- export { CountLatch } from './count-latch';
@@ -1,22 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /**
3
- * 从T里面排除U里相同的属性后剩下的属性组成的类型
4
- */
5
- export type OmitObject<T, U> = { [K in keyof Omit<T, keyof U>]: T[K] };
6
-
7
- /**
8
- * 返回T和U的并集,其中U里面的属性都变成可选
9
- */
10
- export type PartialWithObject<T, U> = {
11
- [K in keyof Omit<T, keyof U>]: T[K];
12
- } & Partial<U>;
13
-
14
- /**
15
- * 从T里面只获取索引类型为string的键
16
- */
17
- export type StrKeyOf<T> = Extract<keyof T, string>;
18
-
19
- /**
20
- * 构造函数接口,声明一个返回对象是T的构造函数,不传则返回类型是any
21
- */
22
- export type Constructor<T extends object = any> = new (...args: any[]) => T;
@@ -1,86 +0,0 @@
1
- import { merge } from 'lodash-es';
2
-
3
- /**
4
- * 文件List转数组
5
- *
6
- * @author lxm
7
- * @date 2022-11-18 13:11:03
8
- * @export
9
- * @param {FileList} fileList
10
- * @returns {*}
11
- */
12
- export function fileListToArr(fileList: FileList): File[] {
13
- const files = [];
14
- for (let i = 0; i < fileList.length; i++) {
15
- files.push(fileList[i]);
16
- }
17
- return files;
18
- }
19
-
20
- /**
21
- * JS打开文件上传操作配置参数
22
- *
23
- * @author lxm
24
- * @date 2022-11-20 21:11:47
25
- * @export
26
- * @interface SelectFileOpts
27
- */
28
- export interface SelectFileOpts {
29
- /**
30
- * 接受的文件类型
31
- *
32
- * @author lxm
33
- * @date 2022-11-20 21:11:52
34
- * @type {string}
35
- */
36
- accept?: string;
37
- /**
38
- * 是否支持多选
39
- *
40
- * @author lxm
41
- * @date 2022-11-20 21:11:52
42
- * @type {boolean}
43
- */
44
- multiple?: boolean;
45
- /**
46
- * 选中文件后回调
47
- *
48
- * @author lxm
49
- * @date 2022-11-20 21:11:50
50
- */
51
- onSelected: (_fileList: File[]) => void;
52
- }
53
-
54
- /**
55
- * JS打开文件上传操作
56
- *
57
- * @author lxm
58
- * @date 2022-11-20 21:11:31
59
- * @export
60
- * @param {SelectFileOpts} _opts 配置参数
61
- */
62
- export function selectFile(_opts: SelectFileOpts): void {
63
- const opts: Required<SelectFileOpts> = merge(
64
- {
65
- multiple: true,
66
- accept: '',
67
- },
68
- _opts,
69
- );
70
- const input = document.createElement('input');
71
- input.setAttribute('type', 'file');
72
- input.setAttribute('multiple', `${opts.multiple}`);
73
- input.setAttribute('accept', opts.accept);
74
- input.onchange = (e): void => {
75
- const inputEl = e.target as HTMLInputElement;
76
- const files = inputEl.files ? fileListToArr(inputEl.files) : [];
77
- if (files.length === 0) {
78
- return;
79
- }
80
- opts.onSelected(files);
81
- inputEl.value = ''; // 如果不置空,相同的文件不会触发change事件
82
- };
83
- document.body.appendChild(input);
84
- input.click();
85
- document.body.removeChild(input);
86
- }
@@ -1,208 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- /* eslint-disable no-param-reassign */
3
- import { cloneDeep, isFunction, merge, round, uniqueId } from 'lodash-es';
4
- import { RuntimeError } from '../../error';
5
- import { HttpResponse } from '../net/http-response';
6
- import { selectFile } from './select-file';
7
-
8
- export interface IUploadFile {
9
- name: string;
10
- uid: string;
11
- status: 'uploading' | 'finished' | 'fail' | 'cancel';
12
- percentage: number;
13
- response?: HttpResponse;
14
- error?: unknown;
15
- }
16
-
17
- export interface IUploadFileOpts {
18
- uploadUrl: string;
19
- /**
20
- * 接受的文件类型
21
- *
22
- * @author lxm
23
- * @date 2022-11-20 21:11:52
24
- * @type {string}
25
- */
26
- accept?: string;
27
- /**
28
- * 是否支持多选
29
- *
30
- * @author lxm
31
- * @date 2022-11-20 21:11:52
32
- * @type {Boolean}
33
- */
34
- multiple?: boolean;
35
- separate?: string;
36
- request?: (_files: File[]) => Promise<HttpResponse>;
37
- beforeUpload?: (_fileData: File[], _files: IUploadFile[]) => boolean;
38
- finish?: (_resultFiles: IUploadFile[]) => void;
39
- success?: (_resultFiles: IUploadFile[], _res: HttpResponse) => void;
40
- error?: (_resultFiles: IUploadFile[], _error: unknown) => void;
41
- progress?: (_files: IUploadFile[]) => void;
42
- }
43
-
44
- /**
45
- * 使用上传文件逻辑
46
- *
47
- * @author lxm
48
- * @date 2022-11-20 21:11:52
49
- * @export
50
- * @param {IUploadFileOpts} _opts
51
- * @returns {*}
52
- */
53
- export function uploadFile(_opts: IUploadFileOpts): void {
54
- const opts: Required<IUploadFileOpts> = merge(
55
- {
56
- multiple: true,
57
- accept: '',
58
- separate: true,
59
- beforeUpload: (_fileData: File[], _files: IUploadFile[]) => true,
60
- finish: (_resultFiles: IUploadFile[]) => {},
61
- success: (_resultFiles: IUploadFile[], _res: HttpResponse) => {},
62
- error: (_resultFiles: IUploadFile[], _error: unknown) => {},
63
- progress: (_files: IUploadFile[]) => {},
64
- },
65
- _opts,
66
- );
67
-
68
- /**
69
- * 进度条回调
70
- *
71
- * @author lxm
72
- * @date 2022-11-20 21:11:47
73
- * @param {IParams} event
74
- * @param {IUploadFile[]} files
75
- */
76
- const onUploadProgress = (event: IParams, files: IUploadFile[]): void => {
77
- files.forEach(file => {
78
- file.percentage = round(event.progress * 100);
79
- });
80
- opts.progress(cloneDeep(files));
81
- };
82
-
83
- /**
84
- * 上传请求方法,返回响应对象
85
- *
86
- * @author lxm
87
- * @date 2022-11-18 13:11:57
88
- * @param {File[]} files
89
- * @returns {*} {Promise<HttpResponse>}
90
- */
91
- const uploadRequest = async (
92
- files: File[],
93
- _onProgress: (_event: IParams) => void,
94
- ): Promise<HttpResponse> => {
95
- // 自定义上传请求
96
- if (opts.request && isFunction(opts.request)) {
97
- return opts.request(files);
98
- }
99
-
100
- // 默认每次单个文件上传,可能存在接口一次上传多个文件,
101
- const data = new FormData();
102
- files.forEach(file => {
103
- data.append('file', file);
104
- });
105
- // const res = await ibiz.net.request(opts.uploadUrl, {
106
- // method: 'post',
107
- // baseURL: '',
108
- // data,
109
- // headers: { 'Content-Type': 'multipart/form-data' },
110
- // onUploadProgress: onProgress,
111
- // });
112
- // return res;
113
- throw new RuntimeError(`多应用模式等待重新实现请求`);
114
- };
115
-
116
- /**
117
- * 执行一次上传,可能是一个文件也可能是多个文件
118
- *
119
- * @author lxm
120
- * @date 2022-11-18 14:11:54
121
- * @param {File[]} files 此次上传文件的集合
122
- * @returns {*} {Promise<IUploadFile[]>}
123
- */
124
- const executeSingleUpload = async (files: File[]): Promise<IUploadFile[]> => {
125
- const resultFiles: IUploadFile[] = files.map(file => {
126
- return {
127
- status: 'uploading',
128
- name: file.name,
129
- uid: uniqueId(),
130
- percentage: 0,
131
- };
132
- });
133
-
134
- // 上传前回调,可以取消此次下载
135
- const pass = opts.beforeUpload(files, resultFiles);
136
- if (!pass) {
137
- resultFiles.forEach(file => {
138
- file.status = 'cancel';
139
- });
140
- ibiz.log.debug('取消上传', resultFiles);
141
- return resultFiles;
142
- }
143
-
144
- try {
145
- const res = await uploadRequest(files, event => {
146
- onUploadProgress(event, resultFiles);
147
- });
148
- resultFiles.forEach(file => {
149
- file.status = 'finished';
150
- });
151
- // 上传成功事件
152
- opts.success(resultFiles, res);
153
- resultFiles.forEach(file => {
154
- file.response = res;
155
- });
156
- } catch (error) {
157
- resultFiles.forEach(file => {
158
- file.status = 'fail';
159
- });
160
- // 上传失败事件
161
- opts.error(resultFiles, error);
162
- resultFiles.forEach(file => {
163
- file.error = error;
164
- });
165
- ibiz.log.error(error);
166
- ibiz.log.error(`${files.map(file => file.name).join(',')}上传失败`);
167
- }
168
- return resultFiles;
169
- };
170
-
171
- /**
172
- * 执行上传文件逻辑
173
- *
174
- * @author lxm
175
- * @date 2022-11-18 13:11:21
176
- * @param {files} File[] 文件集合
177
- */
178
- const uploadFiles = async (files: File[]): Promise<void> => {
179
- const uploadSequence = opts.separate ? files.map(file => [file]) : [files];
180
- const res = await Promise.allSettled(
181
- uploadSequence.map(async sequence => {
182
- return executeSingleUpload(sequence);
183
- }),
184
- );
185
-
186
- // 整合所有的返回文件
187
- const resultFiles: IUploadFile[] = [];
188
- res.forEach(result => {
189
- if (result.status === 'fulfilled') {
190
- resultFiles.push(...result.value);
191
- }
192
- });
193
-
194
- opts.finish(resultFiles);
195
- };
196
-
197
- const select = (): void => {
198
- selectFile({
199
- accept: opts.accept,
200
- multiple: opts.multiple,
201
- onSelected: files => {
202
- uploadFiles(files);
203
- },
204
- });
205
- };
206
-
207
- select();
208
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * 路径解析助手
3
- *
4
- * @author lxm
5
- * @date 2022-10-11 14:10:12
6
- * @export
7
- * @class UrlHelper
8
- */
9
- export class UrlHelper {
10
- /**
11
- * 路由路径前面的基础路径
12
- * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
13
- * 返回:http://172.16.103.120:30061/portalwebapp/#
14
- *
15
- * @author lxm
16
- * @date 2022-10-11 20:10:29
17
- * @returns {*}
18
- */
19
- static get routeBase(): string {
20
- const hashIndex = window.location.href.lastIndexOf('#/');
21
- return window.location.href.slice(0, hashIndex + 1);
22
- }
23
-
24
- /**
25
- * 应用的的基础路径
26
- * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
27
- * 返回:http://172.16.103.120:30061/portalwebapp
28
- *
29
- * @author lxm
30
- * @date 2022-10-11 20:10:29
31
- * @returns {*}
32
- */
33
- static get appBase(): string {
34
- const { origin, pathname } = window.location;
35
- return `${origin}${pathname}`.replace(/\/$/, '');
36
- }
37
-
38
- /**
39
- * #开始到末尾,即路由地址
40
- * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
41
- * 返回:/index/appportalview?params=123
42
- *
43
- * @author lxm
44
- * @date 2022-10-11 16:10:40
45
- * @returns {*}
46
- */
47
- static get routePath(): string {
48
- return window.location.hash.replace('#', '');
49
- }
50
-
51
- /**
52
- * 当前地址的全路径,包含域名和参数
53
- * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
54
- *
55
- * @author lxm
56
- * @date 2022-10-11 21:10:39
57
- * @readonly
58
- * @static
59
- */
60
- static get fullPath(): string {
61
- return window.location.href;
62
- }
63
- }