ztxkutils 10.0.2 → 10.0.3
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/i18next.d.ts +2 -0
- package/dist/i18next.js +2380 -0
- package/dist/index.js +1 -1
- package/dist/{reqUrl-3792afcd.js → reqUrl-ea7ef876.js} +4 -3
- package/dist/{request-3c906c2d.js → request-4c29d6de.js} +76 -12
- package/dist/{request-0cc024b1.js → request-c0970aae.js} +1 -1
- package/dist/request.js +1 -1
- package/dist/test.d.ts +1 -0
- package/dist/{tools-09a4d620.js → tools-390e3466.js} +34 -2
- package/package.json +1 -1
- package/dist/authority-e6bde99f.js +0 -423
- package/dist/reqUrl-787dd9e5.js +0 -82
- package/dist/request-ba8abf99.js +0 -2902
- package/dist/request-ef290b9a.js +0 -2838
- package/dist/validate-6e735536.js +0 -79
package/dist/index.js
CHANGED
@@ -2,7 +2,7 @@ export { d as authority } from './authority-7a91cb9f.js';
|
|
2
2
|
export { d as dataModel } from './dataModel-1fbaff40.js';
|
3
3
|
export { t as tools } from './tools-16a7fb45.js';
|
4
4
|
export { v as validate } from './validate-18e52490.js';
|
5
|
-
export { r as request } from './request-
|
5
|
+
export { r as request } from './request-c0970aae.js';
|
6
6
|
export { r as reqUrl } from './reqUrl-22b880a4.js';
|
7
7
|
import './tslib.es6-35653116.js';
|
8
8
|
import 'dayjs';
|
@@ -5,7 +5,7 @@
|
|
5
5
|
function getReqUrl(processObj) {
|
6
6
|
var ENV = processObj.REACT_APP_ENV;
|
7
7
|
// api服务器各个环境地址
|
8
|
-
var ZT_API_DEV = processObj.REACT_APP_ZT_API_DEV ||
|
8
|
+
var ZT_API_DEV = processObj.REACT_APP_ZT_API_DEV || window.location.origin; // 开发环境
|
9
9
|
var ZT_API_TEST = processObj.REACT_APP_ZT_API_TEST || window.location.origin; // 测试环境 https://192.168.0.135:8000
|
10
10
|
var ZT_API_STAGE = processObj.REACT_APP_ZT_API_STAGE || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
|
11
11
|
var ZT_API_SIM = processObj.REACT_APP_ZT_API_SIM || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
|
@@ -14,9 +14,10 @@ function getReqUrl(processObj) {
|
|
14
14
|
'https://nportal.zmd.com.cn:18998'; // 生产环境外网api地址 https://m-portal.zmd.com.cn:18998 http://dz.zmd.com.cn:48000
|
15
15
|
// 文件服务器
|
16
16
|
var ZT_FILE_PREVIEW_DEV = processObj.REACT_APP_ZT_FILE_PREVIEW_DEV || 'http://192.168.0.83:88'; // 开发环境
|
17
|
-
var ZT_FILE_PREVIEW_TEST = processObj.REACT_APP_ZT_FILE_PREVIEW_TEST ||
|
17
|
+
var ZT_FILE_PREVIEW_TEST = processObj.REACT_APP_ZT_FILE_PREVIEW_TEST ||
|
18
|
+
'http://preview-test.zmdms.com.cn:30079'; // 测试环境 http://172.55.5.101:33013
|
18
19
|
var ZT_FILE_PREVIEW_STAGE = processObj.REACT_APP_ZT_FILE_PREVIEW_STAGE ||
|
19
|
-
'
|
20
|
+
'http://preview-stage.zmdms.com.cn:30079'; // 阶段性环境 https://dzfile-prod.zmd.com.cn/
|
20
21
|
var ZT_FILE_PREVIEW_SIM = processObj.REACT_APP_ZT_FILE_PREVIEW_SIM ||
|
21
22
|
'https://dzfile-data.zmd.com.cn/'; // 阶段性环境 http://192.168.0.134:8012
|
22
23
|
var ZT_FILE_PREVIEW_PRODUCT = processObj.REACT_APP_ZT_FILE_PREVIEW_PRODUCT ||
|
@@ -2480,6 +2480,7 @@ var isNotFound = false; // 404弹框
|
|
2480
2480
|
var isOffSite = false; // 501异地登录
|
2481
2481
|
var isExpiration = false; // 401登录过期
|
2482
2482
|
var catchPromiseObj = []; // 缓存当前宏任务下的缓存
|
2483
|
+
var autonomousCatchingPromiseObj = {}; // 自主缓存。可以自主清空。每个url只对应一个请求
|
2483
2484
|
var __isTimeoutMessage = false; // 是否需要默认展示超时弹框
|
2484
2485
|
var isFirstSet = false; // 首次初始化
|
2485
2486
|
// 'Basic em1kbXM6em1kbXNfc2VjcmV0' 新的auth
|
@@ -2559,6 +2560,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
|
|
2559
2560
|
// 刷新成功 重置token 重置refresh-token
|
2560
2561
|
setToken(data === null || data === void 0 ? void 0 : data.access_token);
|
2561
2562
|
setRefreshToken(data === null || data === void 0 ? void 0 : data.refresh_token);
|
2563
|
+
message.info("token\u5DF2\u7ECF\u5237\u65B0\u6210\u529F\uFF0C\u8BF7\u91CD\u65B0\u63D0\u4EA4\uFF01");
|
2562
2564
|
onAccessTokenFetched();
|
2563
2565
|
isRefreshing = true;
|
2564
2566
|
}
|
@@ -2633,7 +2635,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
|
|
2633
2635
|
return Promise.reject(response);
|
2634
2636
|
}
|
2635
2637
|
}, function (error) {
|
2636
|
-
var _a, _b, _c, _d, _e;
|
2638
|
+
var _a, _b, _c, _d, _e, _f;
|
2637
2639
|
// catchPromiseObj = [];
|
2638
2640
|
console.error(error);
|
2639
2641
|
var errRes = error === null || error === void 0 ? void 0 : error.response;
|
@@ -2647,19 +2649,24 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
|
|
2647
2649
|
params: error === null || error === void 0 ? void 0 : error.config.params,
|
2648
2650
|
});
|
2649
2651
|
});
|
2652
|
+
/** 如果接口出错了,清理掉这个错误的接口缓存 */
|
2653
|
+
var autonomousCatchingKey = ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.autonomousKey) || (error === null || error === void 0 ? void 0 : error.config.url);
|
2654
|
+
if (autonomousCatchingPromiseObj[autonomousCatchingKey]) {
|
2655
|
+
autonomousCatchingPromiseObj[autonomousCatchingKey] = undefined;
|
2656
|
+
}
|
2650
2657
|
if (item !== -1) {
|
2651
2658
|
catchPromiseObj.splice(item, 1);
|
2652
2659
|
}
|
2653
|
-
console.log(error
|
2660
|
+
// console.log(error?.config, catchPromiseObj);
|
2654
2661
|
/** 如果接口出错了,那么清理掉这个错误的接口 */
|
2655
2662
|
// 超时异常统一处理,超时的异常没有response值,只能通过toString处理
|
2656
2663
|
if (!errRes && error.toString().indexOf(timeoutNum + "ms") !== -1) {
|
2657
2664
|
if (!isMessage) {
|
2658
|
-
if (((
|
2665
|
+
if (((_c = (_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === 'POST' &&
|
2659
2666
|
__isTimeoutMessage) {
|
2660
2667
|
isMessage = true;
|
2661
2668
|
Modal.confirm({
|
2662
|
-
title: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF0C\u8BF7\u53BB\u5217\u8868\u786E\u8BA4\u6570\u636E\u662F\u5426\u63D2\u5165\u6210\u529F\uFF0C\u8BF7\u52FF\u91CD\u590D\u63D0\u4EA4\uFF01\n\u63A5\u53E3\u5730\u5740:" + ((
|
2669
|
+
title: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF0C\u8BF7\u53BB\u5217\u8868\u786E\u8BA4\u6570\u636E\u662F\u5426\u63D2\u5165\u6210\u529F\uFF0C\u8BF7\u52FF\u91CD\u590D\u63D0\u4EA4\uFF01\n\u63A5\u53E3\u5730\u5740:" + ((_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.url) + "\n\u8BF7\u6C42\u65B9\u5F0F:" + ((_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.method) + "\n\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4:" + ((_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.timeout),
|
2663
2670
|
okCancel: false,
|
2664
2671
|
onOk: function () {
|
2665
2672
|
isMessage = false;
|
@@ -2766,14 +2773,14 @@ function transformObj(obj) {
|
|
2766
2773
|
return obj;
|
2767
2774
|
}
|
2768
2775
|
function request(myOptions, jumpCallback, otherOptions) {
|
2769
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
2776
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
2770
2777
|
var InnerAuthorization = (otherOptions || {}).InnerAuthorization;
|
2771
2778
|
if (!isFirstSet) {
|
2772
2779
|
setInterceptorsRequest();
|
2773
2780
|
setInterceptorsResponse(jumpCallback, otherOptions);
|
2774
2781
|
isFirstSet = true;
|
2775
2782
|
}
|
2776
|
-
var encryptionType = myOptions.encryptionType, isTimeoutMessage = myOptions.isTimeoutMessage, isForceRequest = myOptions.isForceRequest,
|
2783
|
+
var encryptionType = myOptions.encryptionType, isTimeoutMessage = myOptions.isTimeoutMessage, isForceRequest = myOptions.isForceRequest, _m = myOptions.noCatchUrl, noCatchUrl = _m === void 0 ? [] : _m, isCatch = myOptions.isCatch, mustCatch = myOptions.mustCatch, isAutonomousCatch = myOptions.isAutonomousCatch, _o = myOptions.autonomousCount, autonomousCount = _o === void 0 ? 1 : _o, autonomousKey = myOptions.autonomousKey, options = __rest(myOptions, ["encryptionType", "isTimeoutMessage", "isForceRequest", "noCatchUrl", "isCatch", "mustCatch", "isAutonomousCatch", "autonomousCount", "autonomousKey"]);
|
2777
2784
|
timeoutNum =
|
2778
2785
|
typeof myOptions.timeout === 'number' ? myOptions.timeout : timeoutNum;
|
2779
2786
|
__isTimeoutMessage = isTimeoutMessage;
|
@@ -2787,6 +2794,8 @@ function request(myOptions, jumpCallback, otherOptions) {
|
|
2787
2794
|
'Zmdms-Auth': "bearer " + token,
|
2788
2795
|
'Tenant-Id': '000000',
|
2789
2796
|
Authorization: InnerAuthorization ? InnerAuthorization : Authorization,
|
2797
|
+
// 设置语言包请求头
|
2798
|
+
'Zmdms-Lang': window.localStorage.getItem('languageType') || 'zh_CN',
|
2790
2799
|
},
|
2791
2800
|
};
|
2792
2801
|
if ((_a = options.baseURL) === null || _a === void 0 ? void 0 : _a.endsWith('/')) {
|
@@ -2805,7 +2814,7 @@ function request(myOptions, jumpCallback, otherOptions) {
|
|
2805
2814
|
options.params = transformObj(options.params);
|
2806
2815
|
}
|
2807
2816
|
// 将传入配置与默认配置混合
|
2808
|
-
var newOptions = __assign(__assign(__assign({}, defaultOptions), options), { headers: __assign(__assign({}, defaultOptions.headers), options.headers) });
|
2817
|
+
var newOptions = __assign(__assign(__assign({}, defaultOptions), options), { autonomousKey: autonomousKey, headers: __assign(__assign({}, defaultOptions.headers), options.headers) });
|
2809
2818
|
// 特殊请求处理
|
2810
2819
|
if (((_e = newOptions.method) === null || _e === void 0 ? void 0 : _e.toUpperCase()) === 'POST' ||
|
2811
2820
|
((_f = newOptions.method) === null || _f === void 0 ? void 0 : _f.toUpperCase()) === 'PUT' ||
|
@@ -2849,13 +2858,64 @@ function request(myOptions, jumpCallback, otherOptions) {
|
|
2849
2858
|
};
|
2850
2859
|
}
|
2851
2860
|
}
|
2861
|
+
// 自主缓存请求。默认这个缓存只会针对一个url缓存一次请求
|
2862
|
+
if (isAutonomousCatch) {
|
2863
|
+
var autonomousCatchingKey = autonomousKey || newOptions.url;
|
2864
|
+
var item = autonomousCatchingPromiseObj[autonomousCatchingKey];
|
2865
|
+
// 如果当前接口没有缓存 缓存住,并且返回接口结果
|
2866
|
+
if (!item || !Array.isArray(item)) {
|
2867
|
+
var result = axios(newOptions);
|
2868
|
+
autonomousCatchingPromiseObj[autonomousCatchingKey] = [
|
2869
|
+
{
|
2870
|
+
params: newOptions.params,
|
2871
|
+
promiseObj: result,
|
2872
|
+
method: (_h = newOptions.method) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
|
2873
|
+
},
|
2874
|
+
];
|
2875
|
+
return result;
|
2876
|
+
}
|
2877
|
+
// 如果当前接口有缓存
|
2878
|
+
// 判断当前参数是否命中
|
2879
|
+
var index = item.findIndex(function (itemChild) {
|
2880
|
+
var _a, _b;
|
2881
|
+
return isEqual_1({
|
2882
|
+
method: (_a = itemChild.method) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
2883
|
+
params: itemChild.params,
|
2884
|
+
}, {
|
2885
|
+
method: (_b = newOptions.method) === null || _b === void 0 ? void 0 : _b.toUpperCase(),
|
2886
|
+
params: newOptions.params,
|
2887
|
+
});
|
2888
|
+
});
|
2889
|
+
// 如果缓存命中
|
2890
|
+
if (index !== -1) {
|
2891
|
+
// 最近使用优先
|
2892
|
+
var result = item[index];
|
2893
|
+
item.splice(index, 1);
|
2894
|
+
item.push(result);
|
2895
|
+
return result === null || result === void 0 ? void 0 : result.promiseObj;
|
2896
|
+
}
|
2897
|
+
else {
|
2898
|
+
var result = axios(newOptions);
|
2899
|
+
// 当前接口可以缓存几个结果 如果超过最大缓存数量 删除第一位
|
2900
|
+
if (item.length >= autonomousCount) {
|
2901
|
+
item.shift();
|
2902
|
+
}
|
2903
|
+
item.push({
|
2904
|
+
params: newOptions.params,
|
2905
|
+
promiseObj: result,
|
2906
|
+
method: (_j = newOptions.method) === null || _j === void 0 ? void 0 : _j.toUpperCase(),
|
2907
|
+
});
|
2908
|
+
return result;
|
2909
|
+
}
|
2910
|
+
}
|
2852
2911
|
// 缓存本次宏任务下的GET请求,并且不是以/page结尾的列表分页接口
|
2853
2912
|
// 并且不是强制请求,强制请求需要
|
2854
|
-
if ((((
|
2855
|
-
!((
|
2913
|
+
if (((((_k = newOptions.method) === null || _k === void 0 ? void 0 : _k.toUpperCase()) === 'GET' &&
|
2914
|
+
!((_l = newOptions.url) === null || _l === void 0 ? void 0 : _l.endsWith('/page')) &&
|
2856
2915
|
!noCatchUrl.find(function (item) { var _a; return (_a = newOptions.url) === null || _a === void 0 ? void 0 : _a.endsWith(item); }) &&
|
2857
2916
|
isCatch) ||
|
2858
|
-
mustCatch)
|
2917
|
+
mustCatch) &&
|
2918
|
+
!isAutonomousCatch) {
|
2859
2919
|
// 能不能找到,url与参数都一样得数据
|
2860
2920
|
var index = catchPromiseObj.findIndex(function (item) {
|
2861
2921
|
return isEqual_1({
|
@@ -2899,6 +2959,9 @@ function clearNoCompleteRequest() {
|
|
2899
2959
|
}
|
2900
2960
|
function clearCatch() {
|
2901
2961
|
catchPromiseObj = [];
|
2962
|
+
}
|
2963
|
+
function clearAutonomousCatch(url) {
|
2964
|
+
autonomousCatchingPromiseObj[url] = undefined;
|
2902
2965
|
}
|
2903
2966
|
|
2904
2967
|
var request$1 = /*#__PURE__*/Object.freeze({
|
@@ -2907,7 +2970,8 @@ var request$1 = /*#__PURE__*/Object.freeze({
|
|
2907
2970
|
NEW_AUTHORIZATION: NEW_AUTHORIZATION,
|
2908
2971
|
'default': request,
|
2909
2972
|
clearNoCompleteRequest: clearNoCompleteRequest,
|
2910
|
-
clearCatch: clearCatch
|
2973
|
+
clearCatch: clearCatch,
|
2974
|
+
clearAutonomousCatch: clearAutonomousCatch
|
2911
2975
|
});
|
2912
2976
|
|
2913
|
-
export { NEW_AUTHORIZATION as N, OLD_AUTHORIZATION as O, request as a, clearCatch as b, clearNoCompleteRequest as c, request$1 as r };
|
2977
|
+
export { NEW_AUTHORIZATION as N, OLD_AUTHORIZATION as O, request as a, clearCatch as b, clearNoCompleteRequest as c, clearAutonomousCatch as d, request$1 as r };
|
@@ -2807,7 +2807,7 @@ function request(myOptions, jumpCallback, otherOptions) {
|
|
2807
2807
|
// 将传入配置与默认配置混合
|
2808
2808
|
var newOptions = __assign(__assign(__assign({}, defaultOptions), options), { headers: __assign(__assign({}, defaultOptions.headers), options.headers) });
|
2809
2809
|
// 湘钢国贸项目 除了登录接口外 去掉 Authorization认证头部
|
2810
|
-
if (newOptions.url !== '/api/zmdms-auth/oauth/token') {
|
2810
|
+
if (newOptions.url !== '/api/zmdms-auth/oauth/token' && !InnerAuthorization) {
|
2811
2811
|
delete newOptions.headers.Authorization;
|
2812
2812
|
}
|
2813
2813
|
// 特殊请求处理
|
package/dist/request.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import './tslib.es6-35653116.js';
|
2
2
|
import 'axios';
|
3
3
|
import 'ztxkui';
|
4
|
-
export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, b as clearCatch, c as clearNoCompleteRequest, a as default } from './request-
|
4
|
+
export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, b as clearCatch, c as clearNoCompleteRequest, a as default } from './request-c0970aae.js';
|
5
5
|
import './authority-7a91cb9f.js';
|
6
6
|
import './crypto-c481f616.js';
|
7
7
|
import 'crypto';
|
package/dist/test.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -2208,7 +2208,7 @@ function divide(num1, num2) {
|
|
2208
2208
|
/**
|
2209
2209
|
* @description 精确四舍五入后保留几位小数
|
2210
2210
|
*/
|
2211
|
-
function
|
2211
|
+
function _exactRound(num, ratio) {
|
2212
2212
|
var typeNum = typeof num;
|
2213
2213
|
if (typeNum !== 'number' && typeNum !== 'string') {
|
2214
2214
|
return num;
|
@@ -2222,6 +2222,37 @@ function exactRound(num, ratio) {
|
|
2222
2222
|
return num;
|
2223
2223
|
}
|
2224
2224
|
}
|
2225
|
+
function exactRound(num, ratio) {
|
2226
|
+
var typeNum = typeof num;
|
2227
|
+
if (typeNum !== 'number' && typeNum !== 'string') {
|
2228
|
+
return num;
|
2229
|
+
}
|
2230
|
+
var value = _exactRound(num, ratio);
|
2231
|
+
/**特殊处理单价的小数位,有6位的只显示2位0 */
|
2232
|
+
if (ratio === 6) {
|
2233
|
+
return repairZero(String(Number(value)));
|
2234
|
+
}
|
2235
|
+
return value;
|
2236
|
+
function repairZero(value) {
|
2237
|
+
try {
|
2238
|
+
var arr = value.split('.');
|
2239
|
+
if (arr.length === 2) {
|
2240
|
+
var decimal = arr[1];
|
2241
|
+
if (decimal.length < 2) {
|
2242
|
+
return _exactRound(value, 2);
|
2243
|
+
}
|
2244
|
+
}
|
2245
|
+
else if (arr.length === 1) {
|
2246
|
+
return _exactRound(value, 2);
|
2247
|
+
}
|
2248
|
+
return value;
|
2249
|
+
}
|
2250
|
+
catch (err) {
|
2251
|
+
console.log(err);
|
2252
|
+
return value;
|
2253
|
+
}
|
2254
|
+
}
|
2255
|
+
}
|
2225
2256
|
/**
|
2226
2257
|
* @description 添加千分符符号
|
2227
2258
|
*/
|
@@ -2408,7 +2439,8 @@ function copyContent(text) {
|
|
2408
2439
|
*/
|
2409
2440
|
function dangerouslySetXss(str) {
|
2410
2441
|
var _a;
|
2411
|
-
|
2442
|
+
// 兼容str不是字符串的情况,返回原值
|
2443
|
+
if (!str || typeof str !== 'string') {
|
2412
2444
|
return str;
|
2413
2445
|
}
|
2414
2446
|
try {
|