@ibiz-template/core 0.0.1-alpha.6 → 0.0.1-beta.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/system/index.system.js +1 -0
- package/out/constant/core/core.d.ts +9 -0
- package/out/constant/core/core.d.ts.map +1 -1
- package/out/constant/core/core.js +9 -0
- package/out/constant/index.d.ts +3 -0
- package/out/constant/index.d.ts.map +1 -1
- package/out/constant/index.js +3 -0
- package/out/constant/login-mode/login-mode.d.ts +23 -0
- package/out/constant/login-mode/login-mode.d.ts.map +1 -0
- package/out/constant/login-mode/login-mode.js +24 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
- package/out/constant/util/util.d.ts +5 -0
- package/out/constant/util/util.d.ts.map +1 -0
- package/out/constant/util/util.js +5 -0
- package/out/context/index.d.ts +49 -27
- package/out/context/index.d.ts.map +1 -1
- package/out/context/index.js +94 -55
- package/out/environment/environment.d.ts.map +1 -1
- package/out/environment/environment.js +16 -2
- package/out/error/http-error/http-error.d.ts.map +1 -1
- package/out/error/http-error/http-error.js +0 -4
- package/out/factory-center.d.ts +11 -0
- package/out/factory-center.d.ts.map +1 -0
- package/out/factory-center.js +10 -0
- package/out/ibizsys.d.ts +8 -1
- package/out/ibizsys.d.ts.map +1 -1
- package/out/ibizsys.js +8 -1
- package/out/index.d.ts +2 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/install.d.ts.map +1 -1
- package/out/install.js +4 -2
- package/out/interface/click-outside/click-outside.d.ts +70 -0
- package/out/interface/click-outside/click-outside.d.ts.map +1 -0
- package/out/interface/click-outside/click-outside.js +1 -0
- package/out/interface/i-environment/i-environment.d.ts +108 -4
- package/out/interface/i-environment/i-environment.d.ts.map +1 -1
- package/out/interface/index.d.ts +1 -0
- package/out/interface/index.d.ts.map +1 -1
- package/out/interface/index.js +1 -1
- package/out/types.d.ts +41 -0
- package/out/types.d.ts.map +1 -1
- package/out/utils/click-outside/click-outside.d.ts +14 -0
- package/out/utils/click-outside/click-outside.d.ts.map +1 -0
- package/out/utils/click-outside/click-outside.js +85 -0
- package/out/utils/color/color.d.ts +13 -0
- package/out/utils/color/color.d.ts.map +1 -0
- package/out/utils/color/color.js +76 -0
- package/out/utils/download-file/download-file.d.ts +31 -0
- package/out/utils/download-file/download-file.d.ts.map +1 -0
- package/out/utils/download-file/download-file.js +107 -0
- package/out/utils/event/event.d.ts +34 -0
- package/out/utils/event/event.d.ts.map +1 -0
- package/out/utils/event/event.js +60 -0
- package/out/utils/index.d.ts +11 -1
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +11 -1
- package/out/utils/interceptor/core-interceptor.d.ts +15 -0
- package/out/utils/interceptor/core-interceptor.d.ts.map +1 -0
- package/out/utils/interceptor/core-interceptor.js +30 -0
- package/out/utils/interceptor/index.d.ts +3 -0
- package/out/utils/interceptor/index.d.ts.map +1 -0
- package/out/utils/interceptor/index.js +2 -0
- package/out/utils/interceptor/interceptor.d.ts +74 -3
- package/out/utils/interceptor/interceptor.d.ts.map +1 -1
- package/out/utils/interceptor/interceptor.js +73 -22
- package/out/utils/logger/logger.d.ts +3 -0
- package/out/utils/logger/logger.d.ts.map +1 -0
- package/out/utils/logger/logger.js +2 -0
- package/out/utils/net/http-response.d.ts +4 -9
- package/out/utils/net/http-response.d.ts.map +1 -1
- package/out/utils/net/http-response.js +0 -7
- package/out/utils/net/net.d.ts +98 -30
- package/out/utils/net/net.d.ts.map +1 -1
- package/out/utils/net/net.js +133 -38
- package/out/utils/plural/plural.d.ts.map +1 -1
- package/out/utils/plural/plural.js +2 -0
- package/out/utils/string-util/string-util.d.ts +46 -0
- package/out/utils/string-util/string-util.d.ts.map +1 -0
- package/out/utils/string-util/string-util.js +71 -0
- package/out/utils/sync/await-timeout.d.ts +14 -0
- package/out/utils/sync/await-timeout.d.ts.map +1 -0
- package/out/utils/sync/await-timeout.js +23 -0
- package/out/utils/sync/count-latch.d.ts +60 -0
- package/out/utils/sync/count-latch.d.ts.map +1 -0
- package/out/utils/sync/count-latch.js +90 -0
- package/out/utils/sync/index.d.ts +3 -0
- package/out/utils/sync/index.d.ts.map +1 -0
- package/out/utils/sync/index.js +2 -0
- package/out/utils/upload/select-file.d.ts +53 -0
- package/out/utils/upload/select-file.d.ts.map +1 -0
- package/out/utils/upload/select-file.js +47 -0
- package/out/utils/upload/upload-file.d.ts +46 -0
- package/out/utils/upload/upload-file.d.ts.map +1 -0
- package/out/utils/upload/upload-file.js +150 -0
- package/out/utils/url-helper/url-helper.d.ts +51 -0
- package/out/utils/url-helper/url-helper.d.ts.map +1 -0
- package/out/utils/url-helper/url-helper.js +59 -0
- package/out/utils/util/util.d.ts +20 -4
- package/out/utils/util/util.d.ts.map +1 -1
- package/out/utils/util/util.js +59 -5
- package/package.json +21 -10
- package/src/constant/core/core.ts +10 -0
- package/src/constant/index.ts +3 -0
- package/src/constant/login-mode/login-mode.ts +23 -0
- package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
- package/src/constant/util/util.ts +5 -0
- package/src/context/index.ts +127 -51
- package/src/environment/environment.ts +16 -2
- package/src/error/http-error/http-error.ts +0 -4
- package/src/factory-center.ts +9 -0
- package/src/ibizsys.ts +9 -1
- package/src/index.ts +2 -1
- package/src/install.ts +4 -2
- package/src/interface/click-outside/click-outside.ts +71 -0
- package/src/interface/i-environment/i-environment.ts +122 -4
- package/src/interface/index.ts +1 -0
- package/src/types.ts +45 -0
- package/src/utils/click-outside/click-outside.ts +110 -0
- package/src/utils/color/color.ts +84 -0
- package/src/utils/download-file/download-file.ts +109 -0
- package/src/utils/event/event.ts +77 -0
- package/src/utils/index.ts +11 -1
- package/src/utils/interceptor/core-interceptor.ts +35 -0
- package/src/utils/interceptor/index.ts +2 -0
- package/src/utils/interceptor/interceptor.ts +109 -22
- package/src/utils/logger/logger.ts +3 -0
- package/src/utils/net/http-response.ts +6 -9
- package/src/utils/net/net.ts +171 -50
- package/src/utils/plural/plural.ts +3 -0
- package/src/utils/string-util/string-util.ts +75 -0
- package/src/utils/sync/await-timeout.ts +27 -0
- package/src/utils/sync/count-latch.ts +96 -0
- package/src/utils/sync/index.ts +2 -0
- package/src/utils/upload/select-file.ts +86 -0
- package/src/utils/upload/upload-file.ts +206 -0
- package/src/utils/url-helper/url-helper.ts +62 -0
- package/src/utils/util/util.ts +72 -14
- package/LICENSE +0 -21
package/out/utils/util/util.js
CHANGED
|
@@ -25,10 +25,11 @@ export function getToken() {
|
|
|
25
25
|
*/
|
|
26
26
|
export function isOverlap(arr1, arr2) {
|
|
27
27
|
const newArr = Array.from(new Set([...arr1, ...arr2]));
|
|
28
|
-
return newArr.length
|
|
28
|
+
return newArr.length !== arr1.length + arr2.length;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 防抖并合并每次的参数,
|
|
32
|
+
* 最后一次才会执行
|
|
32
33
|
*
|
|
33
34
|
* @author lxm
|
|
34
35
|
* @date 2022-09-20 21:09:53
|
|
@@ -40,17 +41,16 @@ export function isOverlap(arr1, arr2) {
|
|
|
40
41
|
* newParams: Parameters<T>,
|
|
41
42
|
* ) => Parameters<T>} mergeFunc 合并的回调函数
|
|
42
43
|
* @param {number} [wait] 防抖的延迟毫秒数
|
|
43
|
-
* @param {DebounceSettings} [options] 防抖函数的额外参数
|
|
44
44
|
* @returns {*}
|
|
45
45
|
*/
|
|
46
|
-
export function debounceAndMerge(func, mergeFunc, wait
|
|
46
|
+
export function debounceAndMerge(func, mergeFunc, wait) {
|
|
47
47
|
// 缓存上一次的函数参数
|
|
48
48
|
let oldParams;
|
|
49
49
|
const debounceFunc = debounce((...params) => {
|
|
50
50
|
// 防抖函数执行的时候清空缓存参数
|
|
51
51
|
oldParams = undefined;
|
|
52
52
|
return func(...params);
|
|
53
|
-
}, wait
|
|
53
|
+
}, wait);
|
|
54
54
|
return (...args) => {
|
|
55
55
|
// 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
|
|
56
56
|
let newParams = args;
|
|
@@ -61,3 +61,57 @@ export function debounceAndMerge(func, mergeFunc, wait, options) {
|
|
|
61
61
|
return debounceFunc(...newParams);
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* 防抖并合并每次的参数,最后一次才会执行
|
|
66
|
+
* 绑定方法为异步方法,给每次调用返回最终执行那次的结果
|
|
67
|
+
*
|
|
68
|
+
* @author lxm
|
|
69
|
+
* @date 2022-09-20 21:09:53
|
|
70
|
+
* @export
|
|
71
|
+
* @template T
|
|
72
|
+
* @param {T} func 要防抖的函数
|
|
73
|
+
* @param {(
|
|
74
|
+
* oldParams: Parameters<T>,
|
|
75
|
+
* newParams: Parameters<T>,
|
|
76
|
+
* ) => Parameters<T>} mergeFunc 合并的回调函数
|
|
77
|
+
* @param {number} [wait] 防抖的延迟毫秒数
|
|
78
|
+
* @returns {*}
|
|
79
|
+
*/
|
|
80
|
+
export function debounceAndAsyncMerge(func, mergeFunc, wait) {
|
|
81
|
+
// 缓存上一次的函数参数
|
|
82
|
+
let oldParams;
|
|
83
|
+
let promises = [];
|
|
84
|
+
const debounceFunc = debounce(async (...params) => {
|
|
85
|
+
// 防抖函数执行的时候清空缓存参数
|
|
86
|
+
oldParams = undefined;
|
|
87
|
+
try {
|
|
88
|
+
const result = await func(...params);
|
|
89
|
+
promises.forEach(promise => {
|
|
90
|
+
promise.resolve(result);
|
|
91
|
+
});
|
|
92
|
+
promises = [];
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
promises.forEach(promise => {
|
|
97
|
+
promise.reject(error);
|
|
98
|
+
});
|
|
99
|
+
promises = [];
|
|
100
|
+
}
|
|
101
|
+
}, wait);
|
|
102
|
+
const fun = async (...args) => {
|
|
103
|
+
// 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
|
|
104
|
+
let newParams = args;
|
|
105
|
+
if (oldParams) {
|
|
106
|
+
newParams = mergeFunc(oldParams, newParams);
|
|
107
|
+
}
|
|
108
|
+
oldParams = newParams;
|
|
109
|
+
// 执行防抖函数
|
|
110
|
+
debounceFunc(...newParams);
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
// 阻塞当前调用,当防抖函数被执行后返回
|
|
113
|
+
promises.push({ resolve, reject });
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
return fun;
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-beta.130",
|
|
4
4
|
"description": "核心包",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "out/index.js",
|
|
6
7
|
"types": "out/index.d.ts",
|
|
8
|
+
"system": "./dist/system/index.system.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://gitee.com/iBizModeling/ibiz-template.git"
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
14
|
+
"dist",
|
|
8
15
|
"out",
|
|
9
16
|
"src"
|
|
10
17
|
],
|
|
11
18
|
"scripts": {
|
|
12
19
|
"dev": "tsc --watch",
|
|
13
|
-
"build": "npm run lint && npm run clean && tsc --build",
|
|
20
|
+
"build": "npm run lint && npm run clean && npm run build:rollup && tsc --build",
|
|
21
|
+
"build:rollup": "rollup -c",
|
|
14
22
|
"lint": "eslint 'src/**/*.ts'",
|
|
15
23
|
"lint:fix": "eslint --fix 'src/**/*.ts'",
|
|
16
|
-
"clean": "rimraf out",
|
|
24
|
+
"clean": "rimraf out dist",
|
|
17
25
|
"test": "jest",
|
|
18
|
-
"
|
|
19
|
-
"publish:
|
|
26
|
+
"prepublish": "npm run build",
|
|
27
|
+
"publish:next": "npm publish --access public --tag next",
|
|
28
|
+
"publish:npm": "npm publish --access public"
|
|
20
29
|
},
|
|
21
30
|
"author": "chitanda",
|
|
22
31
|
"license": "MIT",
|
|
23
32
|
"dependencies": {
|
|
24
|
-
"axios": "^
|
|
33
|
+
"axios": "^1.2.1",
|
|
34
|
+
"loglevel": "^1.8.0",
|
|
25
35
|
"pluralize": "^8.0.0",
|
|
26
36
|
"qs": "^6.11.0"
|
|
27
37
|
},
|
|
@@ -29,11 +39,12 @@
|
|
|
29
39
|
"@types/pluralize": "^0.0.29",
|
|
30
40
|
"@types/qs": "^6.9.7",
|
|
31
41
|
"lodash-es": "^4.17.21",
|
|
32
|
-
"qx-util": "^0.4.
|
|
42
|
+
"qx-util": "^0.4.8",
|
|
43
|
+
"ramda": "^0.28.0"
|
|
33
44
|
},
|
|
34
45
|
"peerDependencies": {
|
|
35
46
|
"lodash-es": "^4.17.21",
|
|
36
|
-
"qx-util": "^0.4.
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
"qx-util": "^0.4.8",
|
|
48
|
+
"ramda": "^0.28.0"
|
|
49
|
+
}
|
|
39
50
|
}
|
|
@@ -20,4 +20,14 @@ export class CoreConst {
|
|
|
20
20
|
* @static
|
|
21
21
|
*/
|
|
22
22
|
static readonly TOKEN = 'access_token';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 访问令牌标识过期时间
|
|
26
|
+
*
|
|
27
|
+
* @author lxm
|
|
28
|
+
* @date 2023-02-13 07:11:33
|
|
29
|
+
* @static
|
|
30
|
+
* @memberof CoreConst
|
|
31
|
+
*/
|
|
32
|
+
static readonly TOKEN_EXPIRES = 'access_token_expires';
|
|
23
33
|
}
|
package/src/constant/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/context/index.ts
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable no-constructor-return */
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
/* eslint-disable max-classes-per-file */
|
|
5
|
-
/**
|
|
6
|
-
* 上下文代理处理
|
|
7
|
-
*
|
|
8
|
-
* @author chitanda
|
|
9
|
-
* @date 2022-07-14 10:07:45
|
|
10
|
-
* @class IBizContextProxyHandle
|
|
11
|
-
* @implements {ProxyHandler<IBizContext>}
|
|
12
|
-
*/
|
|
13
|
-
export class IBizContextProxyHandle implements ProxyHandler<IBizContext> {
|
|
14
|
-
set(target: IBizContext, p: string | symbol, value: unknown): boolean {
|
|
15
|
-
target.context[p] = value;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get(target: IBizContext, p: string | symbol, _receiver: unknown): unknown {
|
|
20
|
-
if (target[p] !== undefined) {
|
|
21
|
-
return target[p];
|
|
22
|
-
}
|
|
23
|
-
if (target.context[p] !== undefined) {
|
|
24
|
-
return target.context[p];
|
|
25
|
-
}
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
if ((target as any)._parent && (target as any)._parent[p] !== undefined) {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
return (target as any)._parent[p];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
import { clone } from 'ramda';
|
|
33
2
|
|
|
34
3
|
/**
|
|
35
4
|
* 上下文处理类
|
|
@@ -44,50 +13,157 @@ export class IBizContext implements IContext {
|
|
|
44
13
|
[key: string | symbol]: any;
|
|
45
14
|
|
|
46
15
|
/**
|
|
47
|
-
*
|
|
16
|
+
* clone 后引用的上下文实例,需要在实例销毁时,同时销毁
|
|
48
17
|
*
|
|
49
18
|
* @author chitanda
|
|
50
|
-
* @date
|
|
19
|
+
* @date 2023-03-13 16:03:31
|
|
51
20
|
* @protected
|
|
52
|
-
* @type {
|
|
21
|
+
* @type {IBizContext[]}
|
|
53
22
|
*/
|
|
54
|
-
protected
|
|
23
|
+
protected declare _associationContext: IBizContext[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 修改的父上下文
|
|
27
|
+
*
|
|
28
|
+
* @author lxm
|
|
29
|
+
* @date 2022-12-08 18:12:16
|
|
30
|
+
* @protected
|
|
31
|
+
* @type {IData}
|
|
32
|
+
*/
|
|
33
|
+
protected declare _context: IData;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 父的上下文源对象
|
|
37
|
+
*
|
|
38
|
+
* @author lxm
|
|
39
|
+
* @date 2022-12-08 18:12:31
|
|
40
|
+
* @type {IContext}
|
|
41
|
+
*/
|
|
42
|
+
declare _parent?: IContext;
|
|
55
43
|
|
|
56
44
|
/**
|
|
57
45
|
* Creates an instance of IBizContext.
|
|
58
46
|
*
|
|
59
47
|
* @author chitanda
|
|
60
48
|
* @date 2022-07-14 10:07:15
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
49
|
+
* @param {IData} [context={}] 自身的上下文
|
|
50
|
+
* @param {IContext} [parent]
|
|
63
51
|
*/
|
|
64
|
-
|
|
52
|
+
// eslint-disable-next-line default-param-last
|
|
53
|
+
private constructor(context: IData = {}, parent?: IContext) {
|
|
54
|
+
Object.defineProperty(this, '_associationContext', {
|
|
55
|
+
enumerable: false,
|
|
56
|
+
value: [],
|
|
57
|
+
});
|
|
58
|
+
|
|
65
59
|
if (parent) {
|
|
66
|
-
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
61
|
+
const self = this;
|
|
62
|
+
|
|
63
|
+
// 定义私有变量,存放父上下文源对象
|
|
64
|
+
Object.defineProperty(this, '_parent', {
|
|
65
|
+
enumerable: false,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: parent,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// 定义私有变量,用于存储对父已有上下文的修改。
|
|
71
|
+
Object.defineProperty(this, '_context', {
|
|
72
|
+
enumerable: false,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: {},
|
|
75
|
+
});
|
|
76
|
+
// 监控父上下文参数,自身不存在时从父取
|
|
77
|
+
const properties: { [key: string]: PropertyDescriptor } = {};
|
|
78
|
+
const keys = Object.keys(parent);
|
|
79
|
+
keys.forEach(key => {
|
|
80
|
+
properties[key] = {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
set(val: unknown) {
|
|
83
|
+
if (val == null) {
|
|
84
|
+
self._context[key] = null;
|
|
85
|
+
} else {
|
|
86
|
+
self._context[key] = val;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
get() {
|
|
90
|
+
if (self._context[key] !== undefined) {
|
|
91
|
+
return self._context[key];
|
|
92
|
+
}
|
|
93
|
+
return parent[key];
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperties(this, properties);
|
|
67
98
|
}
|
|
68
|
-
|
|
99
|
+
// 合并给入上下文
|
|
100
|
+
Object.assign(this, context);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 返回自身的上下文,独有的和与父有差异的。
|
|
105
|
+
*
|
|
106
|
+
* @author lxm
|
|
107
|
+
* @date 2022-12-08 17:12:26
|
|
108
|
+
* @returns {*} {IData}
|
|
109
|
+
*/
|
|
110
|
+
getOwnContext(): IData {
|
|
111
|
+
const result: IData = {};
|
|
112
|
+
Object.keys(this).forEach(key => {
|
|
113
|
+
// 父没有的,或者修改了父的上下文
|
|
114
|
+
// 父不存在则返回所有自身的属性
|
|
115
|
+
if (
|
|
116
|
+
!this._parent ||
|
|
117
|
+
!Object.prototype.hasOwnProperty.call(this._parent, key) ||
|
|
118
|
+
Object.prototype.hasOwnProperty.call(this._context, key)
|
|
119
|
+
) {
|
|
120
|
+
result[key] = this[key];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return result;
|
|
69
124
|
}
|
|
70
125
|
|
|
71
126
|
/**
|
|
72
|
-
*
|
|
127
|
+
* 销毁当前上下文对象
|
|
73
128
|
*
|
|
74
129
|
* @author chitanda
|
|
75
|
-
* @date
|
|
76
|
-
|
|
130
|
+
* @date 2023-03-13 15:03:04
|
|
131
|
+
*/
|
|
132
|
+
destroy(): void {
|
|
133
|
+
this._parent = undefined;
|
|
134
|
+
this._context = {};
|
|
135
|
+
this._associationContext.forEach(item => {
|
|
136
|
+
item.destroy();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 在非视图中,需要断开视图上下文联系时。只能使用 clone 创建新的局部上下文
|
|
142
|
+
*
|
|
143
|
+
* @author chitanda
|
|
144
|
+
* @date 2023-03-13 16:03:13
|
|
77
145
|
* @return {*} {IBizContext}
|
|
78
146
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
147
|
+
clone(): IBizContext {
|
|
148
|
+
const newContext = new IBizContext(
|
|
149
|
+
clone(this.getOwnContext()),
|
|
150
|
+
this._parent,
|
|
151
|
+
);
|
|
152
|
+
this._associationContext.push(newContext);
|
|
153
|
+
return newContext;
|
|
81
154
|
}
|
|
82
155
|
|
|
83
156
|
/**
|
|
84
|
-
*
|
|
157
|
+
* 上下文只有在视图初始化时,调用 create 方法
|
|
85
158
|
*
|
|
86
159
|
* @author chitanda
|
|
87
|
-
* @date
|
|
160
|
+
* @date 2023-03-13 16:03:32
|
|
161
|
+
* @static
|
|
162
|
+
* @param {IData} [context]
|
|
163
|
+
* @param {IContext} [parent]
|
|
164
|
+
* @return {*} {IContext}
|
|
88
165
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this._parent = null;
|
|
166
|
+
static create(context?: IData, parent?: IContext): IBizContext {
|
|
167
|
+
return new IBizContext(context, parent);
|
|
92
168
|
}
|
|
93
169
|
}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import { LoginMode, MenuPermissionMode } from '../constant';
|
|
1
2
|
import { IEnvironment } from '../interface';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 环境变量
|
|
5
6
|
*/
|
|
6
7
|
export const Environment: IEnvironment = {
|
|
8
|
+
dev: false,
|
|
9
|
+
logLevel: 'ERROR',
|
|
10
|
+
jsCdn: 'https://cdn.jsdelivr.net',
|
|
7
11
|
baseUrl: '',
|
|
12
|
+
pluginBaseUrl: './plugins',
|
|
8
13
|
remoteModelUrl: '/remotemodel',
|
|
9
14
|
assetsUrl: './assets',
|
|
10
15
|
dcSystem: '',
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
downloadFileUrl: '/ibizutil/download',
|
|
17
|
+
uploadFileUrl: '/ibizutil/upload',
|
|
18
|
+
casLoginUrl: '',
|
|
19
|
+
loginMode: LoginMode.DEFAULT,
|
|
20
|
+
menuPermissionMode: MenuPermissionMode.MIXIN,
|
|
21
|
+
enablePermission: true,
|
|
22
|
+
enableWfAllHistory: false,
|
|
23
|
+
routePlaceholder: '-',
|
|
24
|
+
loginViewName: 'AppLoginView',
|
|
25
|
+
version: '0.0.1',
|
|
26
|
+
favicon: './favicon.ico',
|
|
13
27
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxiosError, AxiosResponse } from 'axios';
|
|
2
|
-
import { HttpStatusMessageConst } from '../../constant';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 请求异常
|
|
@@ -28,9 +27,6 @@ export class HttpError implements Error {
|
|
|
28
27
|
} else {
|
|
29
28
|
this.message = res.statusText;
|
|
30
29
|
}
|
|
31
|
-
if (!this.message) {
|
|
32
|
-
this.message = HttpStatusMessageConst[res.status];
|
|
33
|
-
}
|
|
34
30
|
if (!this.message) {
|
|
35
31
|
this.message = '网络异常,请稍后重试!';
|
|
36
32
|
}
|
package/src/ibizsys.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from './environment/environment';
|
|
2
2
|
import { OrgData } from './interface';
|
|
3
|
-
import { Net } from './utils';
|
|
3
|
+
import { Logger, Net } from './utils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 全局对象
|
|
@@ -19,6 +19,14 @@ export class IBizSys {
|
|
|
19
19
|
*/
|
|
20
20
|
env = Environment;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* 日志对象
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-10-25 20:10:22
|
|
27
|
+
*/
|
|
28
|
+
log = Logger;
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* 网络请求工具类
|
|
24
32
|
*
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import './types';
|
|
2
2
|
|
|
3
3
|
export * from './constant';
|
|
4
|
-
export { IBizContext
|
|
4
|
+
export { IBizContext } from './context';
|
|
5
5
|
export { Environment } from './environment/environment';
|
|
6
6
|
export * from './error';
|
|
7
7
|
export * from './interface';
|
|
8
8
|
export * from './utils';
|
|
9
9
|
export { IBizSys } from './ibizsys';
|
|
10
|
+
export { FactoryCenter } from './factory-center';
|
|
10
11
|
export { install } from './install';
|
package/src/install.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { FactoryCenter } from './factory-center';
|
|
1
2
|
import { IBizSys } from './ibizsys';
|
|
2
|
-
import {
|
|
3
|
+
import { CoreInterceptor } from './utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 初始化全局对象
|
|
@@ -13,5 +14,6 @@ export function install(): void {
|
|
|
13
14
|
throw new Error('ibiz 已经存在, 无需重复安装');
|
|
14
15
|
}
|
|
15
16
|
window.ibiz = new IBizSys();
|
|
16
|
-
new
|
|
17
|
+
window.___fc = new FactoryCenter();
|
|
18
|
+
ibiz.net.addInterceptor('CoreInterceptor', new CoreInterceptor());
|
|
17
19
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 可选配置参数
|
|
3
|
+
*
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2022-10-28 16:10:48
|
|
6
|
+
* @export
|
|
7
|
+
* @interface OnClickOutsideOptions
|
|
8
|
+
* @extends {ConfigurableWindow}
|
|
9
|
+
* @template E
|
|
10
|
+
*/
|
|
11
|
+
export interface OnClickOutsideOptions {
|
|
12
|
+
/**
|
|
13
|
+
* 指定使用的window,不给就用默认的window
|
|
14
|
+
* 一般是在iframe或测试环境中使用。
|
|
15
|
+
*
|
|
16
|
+
* @author lxm
|
|
17
|
+
* @date 2022-10-28 17:10:49
|
|
18
|
+
* @type {Window}
|
|
19
|
+
*/
|
|
20
|
+
window?: Window;
|
|
21
|
+
/**
|
|
22
|
+
* 指定需要忽略的元素,用于排除某些外部的元素
|
|
23
|
+
*
|
|
24
|
+
* @author lxm
|
|
25
|
+
* @date 2022-10-28 17:10:50
|
|
26
|
+
* @type {HTMLElement[]}
|
|
27
|
+
*/
|
|
28
|
+
ignore?: HTMLElement[];
|
|
29
|
+
/**
|
|
30
|
+
* 是否捕获内部元素。默认为是,内部元素不会触发回调。
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
capture?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 回调处理函数类型
|
|
38
|
+
*/
|
|
39
|
+
export type OnClickOutsideHandler = (_evt: PointerEvent | MouseEvent) => void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* OnClickOutside返回对象类型
|
|
43
|
+
*
|
|
44
|
+
* @author lxm
|
|
45
|
+
* @date 2022-10-31 11:10:59
|
|
46
|
+
* @export
|
|
47
|
+
* @interface OnClickOutsideResult
|
|
48
|
+
*/
|
|
49
|
+
export interface OnClickOutsideResult {
|
|
50
|
+
/**
|
|
51
|
+
* 停止监听,并移除相关监听事件
|
|
52
|
+
*
|
|
53
|
+
* @author lxm
|
|
54
|
+
* @date 2022-10-31 11:10:28
|
|
55
|
+
*/
|
|
56
|
+
stop: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* 暂停监听
|
|
59
|
+
*
|
|
60
|
+
* @author lxm
|
|
61
|
+
* @date 2022-10-31 11:10:30
|
|
62
|
+
*/
|
|
63
|
+
pause: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* 继续监听
|
|
66
|
+
*
|
|
67
|
+
* @author lxm
|
|
68
|
+
* @date 2022-10-31 11:10:32
|
|
69
|
+
*/
|
|
70
|
+
proceed: () => void;
|
|
71
|
+
}
|