zmdms-utils 0.0.62 → 0.0.64
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/es/baseUrl.d.ts +15 -1
- package/dist/es/baseUrl.js +23 -22
- package/dist/es/constants.d.ts +2 -2
- package/dist/es/constants.js +2 -2
- package/dist/es/request.d.ts +4 -0
- package/dist/es/request.js +8 -0
- package/package.json +49 -49
- package/src/baseUrl.ts +46 -23
- package/src/constants.ts +2 -2
- package/src/request.ts +9 -0
package/dist/es/baseUrl.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
interface IOptions {
|
|
2
|
+
/** 环境变量key值 */
|
|
3
|
+
envKey: string;
|
|
4
|
+
/** api地址的前缀key */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** 附件服务器前缀key */
|
|
7
|
+
fileKey: string;
|
|
8
|
+
/** 退出登录默认的key */
|
|
9
|
+
logoutKey: string;
|
|
10
|
+
/** 数字中心各个环境key值 */
|
|
11
|
+
cicomsKey?: string;
|
|
12
|
+
/** 外网服务器前缀key值 */
|
|
13
|
+
outKey?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function getBaseUrl(processObj: any, options?: IOptions): {
|
|
2
16
|
API_URL: any;
|
|
3
17
|
CICOMS_API_URL: any;
|
|
4
18
|
FILE_URL: any;
|
package/dist/es/baseUrl.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
// 根据当前环境变量获取基础的URL
|
|
2
|
-
function getBaseUrl(processObj) {
|
|
3
|
-
var
|
|
2
|
+
function getBaseUrl(processObj, options) {
|
|
3
|
+
var _a = options || {}, _b = _a.envKey, envKey = _b === void 0 ? "REACT_APP_ENV" : _b, _c = _a.apiKey, apiKey = _c === void 0 ? "REACT_APP_API" : _c, _d = _a.fileKey, fileKey = _d === void 0 ? "REACT_APP_FILE" : _d, _e = _a.logoutKey, logoutKey = _e === void 0 ? "REACT_APP_LOGOUT" : _e, _f = _a.cicomsKey, cicomsKey = _f === void 0 ? "REACT_APP_CICOMS_API" : _f, _g = _a.outKey, outKey = _g === void 0 ? "REACT_APP_OUTHR_API" : _g;
|
|
4
|
+
var ENV = processObj[envKey]; // 获取当前环境变量
|
|
4
5
|
// api各个环境地址
|
|
5
6
|
var apiBaseUrlObj = {
|
|
6
|
-
dev: processObj.
|
|
7
|
-
test: processObj.
|
|
8
|
-
stage: processObj.
|
|
9
|
-
prod: processObj.
|
|
7
|
+
dev: processObj["".concat(apiKey, "_DEV")] || "http://192.168.0.134:8000",
|
|
8
|
+
test: processObj["".concat(apiKey, "_TEST")] || window.location.origin,
|
|
9
|
+
stage: processObj["".concat(apiKey, "_STAGE")] || window.location.origin,
|
|
10
|
+
prod: processObj["".concat(apiKey, "_PROD")] || window.location.origin,
|
|
10
11
|
};
|
|
11
12
|
// 数字中心各个环境地址
|
|
12
13
|
var cicomsApiBaseUrlObj = {
|
|
13
|
-
dev: processObj.
|
|
14
|
-
test: processObj.
|
|
15
|
-
stage: processObj.
|
|
16
|
-
prod: processObj.
|
|
14
|
+
dev: processObj["".concat(cicomsKey, "_DEV")] || window.location.origin,
|
|
15
|
+
test: processObj["".concat(cicomsKey, "_TEST")] || window.location.origin,
|
|
16
|
+
stage: processObj["".concat(cicomsKey, "_STAGE")] || window.location.origin,
|
|
17
|
+
prod: processObj["".concat(cicomsKey, "_PROD")] || window.location.origin,
|
|
17
18
|
};
|
|
18
19
|
// file 服务器
|
|
19
20
|
var fileBaseUrlObj = {
|
|
20
|
-
dev: processObj.
|
|
21
|
-
test: processObj.
|
|
22
|
-
stage: processObj.
|
|
23
|
-
prod: processObj.
|
|
21
|
+
dev: processObj["".concat(fileKey, "_DEV")] || "http://192.168.0.134:8000",
|
|
22
|
+
test: processObj["".concat(fileKey, "_TEST")] || window.location.origin,
|
|
23
|
+
stage: processObj["".concat(fileKey, "_STAGE")] || window.location.origin,
|
|
24
|
+
prod: processObj["".concat(fileKey, "_PROD")] || window.location.origin,
|
|
24
25
|
};
|
|
25
26
|
// 外网项目各个环境地址
|
|
26
27
|
var outHrDomain = {
|
|
27
|
-
dev: processObj.
|
|
28
|
-
test: processObj.
|
|
29
|
-
stage: processObj.
|
|
30
|
-
prod: processObj.
|
|
28
|
+
dev: processObj["".concat(outKey, "_DEV")] || "http://192.168.0.134:18886",
|
|
29
|
+
test: processObj["".concat(outKey, "_TEST")] || "http://hr-out.cico.com.cn:30601",
|
|
30
|
+
stage: processObj["".concat(outKey, "_STAGE")] || "http://10.100.234.36:18886",
|
|
31
|
+
prod: processObj["".concat(outKey, "_PROD")] || "https://dhr.cncico.com:18443",
|
|
31
32
|
};
|
|
32
33
|
// 退出登录地址
|
|
33
34
|
var logoutUrl = {
|
|
34
|
-
dev: processObj.
|
|
35
|
-
test: processObj.
|
|
36
|
-
stage: processObj.
|
|
37
|
-
prod: processObj.
|
|
35
|
+
dev: processObj["".concat(logoutKey, "_DEV")] || "/login",
|
|
36
|
+
test: processObj["".concat(logoutKey, "_DEV")] || "/login",
|
|
37
|
+
stage: processObj["".concat(logoutKey, "_DEV")] || "http://testportal.cncico.com:8099/",
|
|
38
|
+
prod: processObj["".concat(logoutKey, "_DEV")] || "http://newportal.cncico.com/",
|
|
38
39
|
};
|
|
39
40
|
var currentKey = ENV.toLowerCase() || "prod";
|
|
40
41
|
return {
|
package/dist/es/constants.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const EMITTER_TYPE: {
|
|
|
14
14
|
treeSearchWhitePath: string;
|
|
15
15
|
treeSearchSet: string;
|
|
16
16
|
};
|
|
17
|
-
declare const TOKEN_KEY
|
|
18
|
-
declare const BASIC_KEY
|
|
17
|
+
declare const TOKEN_KEY: any;
|
|
18
|
+
declare const BASIC_KEY: any;
|
|
19
19
|
|
|
20
20
|
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY };
|
package/dist/es/constants.js
CHANGED
|
@@ -21,9 +21,9 @@ var EMITTER_TYPE = {
|
|
|
21
21
|
};
|
|
22
22
|
// token key 值
|
|
23
23
|
// export const TOKEN_KEY = "Zmdms-Auth";
|
|
24
|
-
var TOKEN_KEY = "Cicoms-Auth";
|
|
24
|
+
var TOKEN_KEY = window.__TOKEN_KEY__ || "Cicoms-Auth";
|
|
25
25
|
// 基础前缀
|
|
26
26
|
// export const BASIC_KEY = "zmdms";
|
|
27
|
-
var BASIC_KEY = "cicoms";
|
|
27
|
+
var BASIC_KEY = window.__BASIC_KEY__ || "cicoms";
|
|
28
28
|
|
|
29
29
|
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
|
package/dist/es/request.d.ts
CHANGED
package/dist/es/request.js
CHANGED
|
@@ -34,11 +34,19 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
34
34
|
}
|
|
35
35
|
// 设置axios方法默认值
|
|
36
36
|
AxiosRequest.prototype.defaultSetting = function () {
|
|
37
|
+
var _this = this;
|
|
37
38
|
// 设置默认请求头
|
|
38
39
|
this.instanceAxios.defaults.headers.common["Tenant-Id"] =
|
|
39
40
|
this.otherOptions.TenantId;
|
|
40
41
|
this.instanceAxios.defaults.headers.common["Authorization"] =
|
|
41
42
|
this.otherOptions.Authorization;
|
|
43
|
+
if (this.otherOptions.commonHeaders) {
|
|
44
|
+
Object.keys(this.otherOptions.commonHeaders).forEach(function (key) {
|
|
45
|
+
var _a;
|
|
46
|
+
_this.instanceAxios.defaults.headers.common[key] =
|
|
47
|
+
(_a = _this.otherOptions.commonHeaders) === null || _a === void 0 ? void 0 : _a[key];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
42
50
|
// 其他默认参数
|
|
43
51
|
this.instanceAxios.defaults.timeout = this.otherOptions.timeout;
|
|
44
52
|
this.instanceAxios.defaults.baseURL = this.otherOptions.baseURL;
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "zmdms-utils",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"clean": "rimraf ./dist",
|
|
10
|
-
"build": "npm run clean && npm run build-es",
|
|
11
|
-
"build-es": "npm run clean && rollup --config ./rollup.esm.config.js"
|
|
12
|
-
},
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"axios": "^1.4.0",
|
|
17
|
-
"crypto-js": "^4.1.1",
|
|
18
|
-
"dayjs": "^1.11.7",
|
|
19
|
-
"html2canvas": "^1.4.1",
|
|
20
|
-
"jspdf": "^2.5.1",
|
|
21
|
-
"print-js": "^1.6.0",
|
|
22
|
-
"qiankun": "^2.10.8"
|
|
23
|
-
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"decimal.js": "^10.4.3",
|
|
26
|
-
"jwt-decode": "3.1.2",
|
|
27
|
-
"mitt": "^3.0.0",
|
|
28
|
-
"pinyin-pro": "^3.18.2"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@rollup/plugin-commonjs": "^24.0.1",
|
|
32
|
-
"@rollup/plugin-json": "^6.0.0",
|
|
33
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
34
|
-
"@types/crypto-js": "^4.1.1",
|
|
35
|
-
"axios": "^1.4.0",
|
|
36
|
-
"crypto-js": "^4.1.1",
|
|
37
|
-
"dayjs": "^1.11.10",
|
|
38
|
-
"html2canvas": "^1.4.1",
|
|
39
|
-
"jspdf": "^2.5.1",
|
|
40
|
-
"print-js": "^1.6.0",
|
|
41
|
-
"qiankun": "^2.10.8",
|
|
42
|
-
"rimraf": "^4.4.1",
|
|
43
|
-
"rollup": "^3.20.2",
|
|
44
|
-
"rollup-plugin-dts": "^5.3.0",
|
|
45
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
46
|
-
"rollup-plugin-typescript2": "^0.34.1",
|
|
47
|
-
"typescript": "^5.0.2"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "zmdms-utils",
|
|
3
|
+
"version": "0.0.64",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "rimraf ./dist",
|
|
10
|
+
"build": "npm run clean && npm run build-es",
|
|
11
|
+
"build-es": "npm run clean && rollup --config ./rollup.esm.config.js"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"axios": "^1.4.0",
|
|
17
|
+
"crypto-js": "^4.1.1",
|
|
18
|
+
"dayjs": "^1.11.7",
|
|
19
|
+
"html2canvas": "^1.4.1",
|
|
20
|
+
"jspdf": "^2.5.1",
|
|
21
|
+
"print-js": "^1.6.0",
|
|
22
|
+
"qiankun": "^2.10.8"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"decimal.js": "^10.4.3",
|
|
26
|
+
"jwt-decode": "3.1.2",
|
|
27
|
+
"mitt": "^3.0.0",
|
|
28
|
+
"pinyin-pro": "^3.18.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
32
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
34
|
+
"@types/crypto-js": "^4.1.1",
|
|
35
|
+
"axios": "^1.4.0",
|
|
36
|
+
"crypto-js": "^4.1.1",
|
|
37
|
+
"dayjs": "^1.11.10",
|
|
38
|
+
"html2canvas": "^1.4.1",
|
|
39
|
+
"jspdf": "^2.5.1",
|
|
40
|
+
"print-js": "^1.6.0",
|
|
41
|
+
"qiankun": "^2.10.8",
|
|
42
|
+
"rimraf": "^4.4.1",
|
|
43
|
+
"rollup": "^3.20.2",
|
|
44
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
45
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
46
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
47
|
+
"typescript": "^5.0.2"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/baseUrl.ts
CHANGED
|
@@ -1,47 +1,70 @@
|
|
|
1
|
+
interface IOptions {
|
|
2
|
+
/** 环境变量key值 */
|
|
3
|
+
envKey: string;
|
|
4
|
+
/** api地址的前缀key */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** 附件服务器前缀key */
|
|
7
|
+
fileKey: string;
|
|
8
|
+
/** 退出登录默认的key */
|
|
9
|
+
logoutKey: string;
|
|
10
|
+
/** 数字中心各个环境key值 */
|
|
11
|
+
cicomsKey?: string;
|
|
12
|
+
/** 外网服务器前缀key值 */
|
|
13
|
+
outKey?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
// 根据当前环境变量获取基础的URL
|
|
2
|
-
export function getBaseUrl(processObj: any) {
|
|
3
|
-
const
|
|
17
|
+
export function getBaseUrl(processObj: any, options?: IOptions) {
|
|
18
|
+
const {
|
|
19
|
+
envKey = "REACT_APP_ENV",
|
|
20
|
+
apiKey = "REACT_APP_API",
|
|
21
|
+
fileKey = "REACT_APP_FILE",
|
|
22
|
+
logoutKey = "REACT_APP_LOGOUT",
|
|
23
|
+
cicomsKey = "REACT_APP_CICOMS_API",
|
|
24
|
+
outKey = "REACT_APP_OUTHR_API",
|
|
25
|
+
} = options || {};
|
|
26
|
+
|
|
27
|
+
const ENV = processObj[envKey]; // 获取当前环境变量
|
|
4
28
|
|
|
5
29
|
// api各个环境地址
|
|
6
30
|
const apiBaseUrlObj: any = {
|
|
7
|
-
dev: processObj
|
|
8
|
-
test: processObj
|
|
9
|
-
stage: processObj
|
|
10
|
-
prod: processObj
|
|
31
|
+
dev: processObj[`${apiKey}_DEV`] || "http://192.168.0.134:8000",
|
|
32
|
+
test: processObj[`${apiKey}_TEST`] || window.location.origin,
|
|
33
|
+
stage: processObj[`${apiKey}_STAGE`] || window.location.origin,
|
|
34
|
+
prod: processObj[`${apiKey}_PROD`] || window.location.origin,
|
|
11
35
|
};
|
|
12
36
|
|
|
13
37
|
// 数字中心各个环境地址
|
|
14
38
|
const cicomsApiBaseUrlObj: any = {
|
|
15
|
-
dev: processObj
|
|
16
|
-
test: processObj
|
|
17
|
-
stage: processObj
|
|
18
|
-
prod: processObj
|
|
39
|
+
dev: processObj[`${cicomsKey}_DEV`] || window.location.origin,
|
|
40
|
+
test: processObj[`${cicomsKey}_TEST`] || window.location.origin,
|
|
41
|
+
stage: processObj[`${cicomsKey}_STAGE`] || window.location.origin,
|
|
42
|
+
prod: processObj[`${cicomsKey}_PROD`] || window.location.origin,
|
|
19
43
|
};
|
|
20
44
|
|
|
21
45
|
// file 服务器
|
|
22
46
|
const fileBaseUrlObj: any = {
|
|
23
|
-
dev: processObj
|
|
24
|
-
test: processObj
|
|
25
|
-
stage: processObj
|
|
26
|
-
prod: processObj
|
|
47
|
+
dev: processObj[`${fileKey}_DEV`] || "http://192.168.0.134:8000",
|
|
48
|
+
test: processObj[`${fileKey}_TEST`] || window.location.origin,
|
|
49
|
+
stage: processObj[`${fileKey}_STAGE`] || window.location.origin,
|
|
50
|
+
prod: processObj[`${fileKey}_PROD`] || window.location.origin,
|
|
27
51
|
};
|
|
28
52
|
|
|
29
53
|
// 外网项目各个环境地址
|
|
30
54
|
const outHrDomain: any = {
|
|
31
|
-
dev: processObj
|
|
32
|
-
test:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
prod: processObj.REACT_APP_OUTHR_API_PROD || "https://dhr.cncico.com:18443",
|
|
55
|
+
dev: processObj[`${outKey}_DEV`] || "http://192.168.0.134:18886",
|
|
56
|
+
test: processObj[`${outKey}_TEST`] || "http://hr-out.cico.com.cn:30601",
|
|
57
|
+
stage: processObj[`${outKey}_STAGE`] || "http://10.100.234.36:18886",
|
|
58
|
+
prod: processObj[`${outKey}_PROD`] || "https://dhr.cncico.com:18443",
|
|
36
59
|
};
|
|
37
60
|
|
|
38
61
|
// 退出登录地址
|
|
39
62
|
const logoutUrl: any = {
|
|
40
|
-
dev: processObj
|
|
41
|
-
test: processObj
|
|
63
|
+
dev: processObj[`${logoutKey}_DEV`] || "/login",
|
|
64
|
+
test: processObj[`${logoutKey}_DEV`] || "/login",
|
|
42
65
|
stage:
|
|
43
|
-
processObj
|
|
44
|
-
prod: processObj
|
|
66
|
+
processObj[`${logoutKey}_DEV`] || "http://testportal.cncico.com:8099/",
|
|
67
|
+
prod: processObj[`${logoutKey}_DEV`] || "http://newportal.cncico.com/",
|
|
45
68
|
};
|
|
46
69
|
|
|
47
70
|
const currentKey = ENV.toLowerCase() || "prod";
|
package/src/constants.ts
CHANGED
|
@@ -26,8 +26,8 @@ export const EMITTER_TYPE = {
|
|
|
26
26
|
|
|
27
27
|
// token key 值
|
|
28
28
|
// export const TOKEN_KEY = "Zmdms-Auth";
|
|
29
|
-
export const TOKEN_KEY = "Cicoms-Auth";
|
|
29
|
+
export const TOKEN_KEY = (window as any).__TOKEN_KEY__ || "Cicoms-Auth";
|
|
30
30
|
|
|
31
31
|
// 基础前缀
|
|
32
32
|
// export const BASIC_KEY = "zmdms";
|
|
33
|
-
export const BASIC_KEY = "cicoms";
|
|
33
|
+
export const BASIC_KEY = (window as any).__BASIC_KEY__ || "cicoms";
|
package/src/request.ts
CHANGED
|
@@ -67,6 +67,13 @@ export class AxiosRequest {
|
|
|
67
67
|
this.instanceAxios.defaults.headers.common["Authorization"] =
|
|
68
68
|
this.otherOptions.Authorization;
|
|
69
69
|
|
|
70
|
+
if (this.otherOptions.commonHeaders) {
|
|
71
|
+
Object.keys(this.otherOptions.commonHeaders).forEach((key) => {
|
|
72
|
+
this.instanceAxios.defaults.headers.common[key] =
|
|
73
|
+
this.otherOptions.commonHeaders?.[key];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
70
77
|
// 其他默认参数
|
|
71
78
|
this.instanceAxios.defaults.timeout = this.otherOptions.timeout;
|
|
72
79
|
this.instanceAxios.defaults.baseURL = this.otherOptions.baseURL;
|
|
@@ -399,6 +406,8 @@ export interface IOtherOptions {
|
|
|
399
406
|
TenantId?: string;
|
|
400
407
|
/** auth值 */
|
|
401
408
|
Authorization?: string;
|
|
409
|
+
/** 公用请求头 */
|
|
410
|
+
commonHeaders?: { [prop: string]: any };
|
|
402
411
|
/** 超时时间 */
|
|
403
412
|
timeout?: number;
|
|
404
413
|
/** 基础url */
|