ztxkutils 2.10.66-29 → 2.10.66-30

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.
@@ -0,0 +1,26 @@
1
+ import instance from './i18next.js';
2
+
3
+ /**
4
+ * @description 数据模型创建
5
+ */
6
+ function createSuccessModel(data, message) {
7
+ return {
8
+ data: data,
9
+ message: message || instance.t('数据请求成功'),
10
+ success: true,
11
+ };
12
+ }
13
+ function createErrorModel(message) {
14
+ return {
15
+ message: message || instance.t('数据请求失败'),
16
+ success: false,
17
+ };
18
+ }
19
+
20
+ var dataModel = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ createSuccessModel: createSuccessModel,
23
+ createErrorModel: createErrorModel
24
+ });
25
+
26
+ export { createErrorModel as a, createSuccessModel as c, dataModel as d };
@@ -0,0 +1,26 @@
1
+ import instance from './i18next.js';
2
+
3
+ /**
4
+ * @description 数据模型创建
5
+ */
6
+ function createSuccessModel(data, message) {
7
+ return {
8
+ data: data,
9
+ message: message || instance.t('数据请求成功'),
10
+ success: true,
11
+ };
12
+ }
13
+ function createErrorModel(message) {
14
+ return {
15
+ message: message || instance.t('数据请求失败'),
16
+ success: false,
17
+ };
18
+ }
19
+
20
+ var dataModel = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ createSuccessModel: createSuccessModel,
23
+ createErrorModel: createErrorModel
24
+ });
25
+
26
+ export { createErrorModel as a, createSuccessModel as c, dataModel as d };
@@ -0,0 +1,26 @@
1
+ import instance from './i18next.js';
2
+
3
+ /**
4
+ * @description 数据模型创建
5
+ */
6
+ function createSuccessModel(data, message) {
7
+ return {
8
+ data: data,
9
+ message: message || instance.t('数据请求成功'),
10
+ success: true,
11
+ };
12
+ }
13
+ function createErrorModel(message) {
14
+ return {
15
+ message: message || instance.t('数据请求失败'),
16
+ success: false,
17
+ };
18
+ }
19
+
20
+ var dataModel = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ createSuccessModel: createSuccessModel,
23
+ createErrorModel: createErrorModel
24
+ });
25
+
26
+ export { createErrorModel as a, createSuccessModel as c, dataModel as d };
package/dist/dataModel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import './i18next.js';
2
- export { a as createErrorModel, c as createSuccessModel } from './dataModel-6c68c88f.js';
2
+ export { a as createErrorModel, c as createSuccessModel } from './dataModel-f1ef06bc.js';
package/dist/i18next.js CHANGED
@@ -2378,23 +2378,23 @@ instance.loadNamespaces;
2378
2378
  instance.loadLanguages;
2379
2379
 
2380
2380
  var originalT = instance.t;
2381
- // 直接修改原始函数的行为,在获取不到翻译时返回 key
2382
- var t = originalT;
2383
- Object.defineProperty(t, 'bind', {
2384
- value: function (context) {
2385
- var boundFn = originalT.bind(context);
2386
- return function () {
2387
- var args = [];
2388
- for (var _i = 0; _i < arguments.length; _i++) {
2389
- args[_i] = arguments[_i];
2390
- }
2391
- if (!args[0])
2392
- return args[0];
2393
- var result = boundFn.apply(void 0, args);
2394
- // 为了兼容enum中value翻译的情况
2395
- return (result || args[0]);
2396
- };
2397
- },
2381
+ var getSourceKey = function (key, params) {
2382
+ if (params) {
2383
+ var keys = Object.keys(params);
2384
+ if (keys.length) {
2385
+ return keys.reduce(function (pre, cur) {
2386
+ return pre.replace("{{" + cur + "}}", params[cur]);
2387
+ }, key);
2388
+ }
2389
+ }
2390
+ return key;
2391
+ };
2392
+ var t = (function () {
2393
+ var args = [];
2394
+ for (var _i = 0; _i < arguments.length; _i++) {
2395
+ args[_i] = arguments[_i];
2396
+ }
2397
+ return originalT.apply(void 0, args) || getSourceKey(args === null || args === void 0 ? void 0 : args[0], args === null || args === void 0 ? void 0 : args[1]);
2398
2398
  });
2399
2399
  instance.t = t;
2400
2400
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { d as authority } from './authority-7a91cb9f.js';
2
- export { d as dataModel } from './dataModel-6c68c88f.js';
2
+ export { d as dataModel } from './dataModel-f1ef06bc.js';
3
3
  export { t as tools } from './tools-390e3466.js';
4
- export { v as validate } from './validate-eccfa73c.js';
5
- export { r as request } from './request-d8d72b87.js';
4
+ export { v as validate } from './validate-2138d94a.js';
5
+ export { r as request } from './request-40e9ca7b.js';
6
6
  export { r as reqUrl } from './reqUrl-ea7ef876.js';
7
7
  import './i18next.js';
8
8
  import './tslib.es6-35653116.js';
@@ -1,4 +1,5 @@
1
1
  import { a as __rest, _ as __assign } from './tslib.es6-35653116.js';
2
+ import instance from './i18next.js';
2
3
  import axios from 'axios';
3
4
  import { Modal, message } from 'ztxkui';
4
5
  import { c as commonjsGlobal, a as crypto } from './crypto-c481f616.js';
@@ -2452,7 +2453,7 @@ var AxiosCancel = /** @class */ (function () {
2452
2453
  // 将token挂载到当前接口的请求头里面
2453
2454
  config.cancelToken = cancelTokenObj.token;
2454
2455
  if (this.pendingRequests.has(key)) {
2455
- this.pendingRequests.get(key).cancel('拦截重复请求');
2456
+ this.pendingRequests.get(key).cancel(instance.t('拦截重复请求'));
2456
2457
  this.pendingRequests.delete(key);
2457
2458
  }
2458
2459
  this.pendingRequests.set(key, {
@@ -2512,7 +2513,7 @@ function checkStatus(response, jumpCallback, otherOptions) {
2512
2513
  refreshTokenRequst(jumpCallback, InnerAuthorization);
2513
2514
  }
2514
2515
  else {
2515
- message.info("\u5237\u65B0token\u906D\u5230\u9891\u7E41\u8C03\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u67E5\u770B\u662F\u5426\u63A5\u53E3\u6743\u9650\u51FA\u73B0\u95EE\u9898\uFF0C\u53EF\u80FD\u662F" + (response === null || response === void 0 ? void 0 : response.config.url) + "\u63A5\u53E3\u51FA\u73B0\u95EE\u9898", 5);
2516
+ message.info(instance.t('刷新token遭到频繁调用,请联系管理员查看是否接口权限出现问题,可能是{{slot0}}接口出现问题', { slot0: response === null || response === void 0 ? void 0 : response.config.url }), 5);
2516
2517
  requestTokenEndTime = 0;
2517
2518
  }
2518
2519
  }
@@ -2560,6 +2561,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2560
2561
  // 刷新成功 重置token 重置refresh-token
2561
2562
  setToken(data === null || data === void 0 ? void 0 : data.access_token);
2562
2563
  setRefreshToken(data === null || data === void 0 ? void 0 : data.refresh_token);
2564
+ message.info(instance.t('token已经刷新成功,请重新提交!', {}));
2563
2565
  onAccessTokenFetched();
2564
2566
  isRefreshing = true;
2565
2567
  }
@@ -2573,7 +2575,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2573
2575
  jumpCallback(401);
2574
2576
  }
2575
2577
  else {
2576
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2578
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2577
2579
  isExpiration = false;
2578
2580
  });
2579
2581
  window.location.href = '/login';
@@ -2589,7 +2591,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2589
2591
  jumpCallback(401);
2590
2592
  }
2591
2593
  else {
2592
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2594
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2593
2595
  isExpiration = false;
2594
2596
  });
2595
2597
  window.location.href = '/login';
@@ -2665,7 +2667,11 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2665
2667
  __isTimeoutMessage) {
2666
2668
  isMessage = true;
2667
2669
  Modal.confirm({
2668
- 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),
2670
+ title: instance.t('请求超时,请稍后再试,请去列表确认数据是否插入成功,请勿重复提交! 接口地址:{{slot0}} 请求方式:{{slot1}} 请求超时时间:{{slot2}}', {
2671
+ slot0: (_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.url,
2672
+ slot1: (_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.method,
2673
+ slot2: (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.timeout,
2674
+ }),
2669
2675
  okCancel: false,
2670
2676
  onOk: function () {
2671
2677
  isMessage = false;
@@ -2679,7 +2685,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2679
2685
  if ((errRes === null || errRes === void 0 ? void 0 : errRes.status) === 404) {
2680
2686
  if (!isNotFound) {
2681
2687
  isNotFound = true;
2682
- message.info("\u63A5\u53E3: " + errRes.config.url + " \u672A\u627E\u5230\uFF01", 3.5, function () {
2688
+ message.info(instance.t('接口: {{slot0}} 未找到!', { slot0: errRes.config.url }), 3.5, function () {
2683
2689
  isNotFound = false;
2684
2690
  });
2685
2691
  }
@@ -2695,7 +2701,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2695
2701
  jumpCallback(errRes === null || errRes === void 0 ? void 0 : errRes.status);
2696
2702
  }
2697
2703
  else {
2698
- message.info("\u4F60\u7684\u8D26\u53F7\u5DF2\u5728\u5176\u4ED6\u5730\u65B9\u767B\u5F55\uFF01", 3.5, function () {
2704
+ message.info(instance.t('你的账号已在其他地方登录!', {}), 3.5, function () {
2699
2705
  isOffSite = false;
2700
2706
  });
2701
2707
  window.location.href = '/login';
@@ -2713,7 +2719,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2713
2719
  jumpCallback(errRes === null || errRes === void 0 ? void 0 : errRes.status);
2714
2720
  }
2715
2721
  else {
2716
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2722
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2717
2723
  isExpiration = false;
2718
2724
  });
2719
2725
  window.location.href = '/login';
@@ -1,4 +1,5 @@
1
1
  import { a as __rest, _ as __assign } from './tslib.es6-35653116.js';
2
+ import instance from './i18next.js';
2
3
  import axios from 'axios';
3
4
  import { Modal, message } from 'ztxkui';
4
5
  import { c as commonjsGlobal, a as crypto } from './crypto-c481f616.js';
@@ -2452,7 +2453,7 @@ var AxiosCancel = /** @class */ (function () {
2452
2453
  // 将token挂载到当前接口的请求头里面
2453
2454
  config.cancelToken = cancelTokenObj.token;
2454
2455
  if (this.pendingRequests.has(key)) {
2455
- this.pendingRequests.get(key).cancel('拦截重复请求');
2456
+ this.pendingRequests.get(key).cancel(instance.t('拦截重复请求'));
2456
2457
  this.pendingRequests.delete(key);
2457
2458
  }
2458
2459
  this.pendingRequests.set(key, {
@@ -2512,7 +2513,7 @@ function checkStatus(response, jumpCallback, otherOptions) {
2512
2513
  refreshTokenRequst(jumpCallback, InnerAuthorization);
2513
2514
  }
2514
2515
  else {
2515
- message.info("\u5237\u65B0token\u906D\u5230\u9891\u7E41\u8C03\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u67E5\u770B\u662F\u5426\u63A5\u53E3\u6743\u9650\u51FA\u73B0\u95EE\u9898\uFF0C\u53EF\u80FD\u662F" + (response === null || response === void 0 ? void 0 : response.config.url) + "\u63A5\u53E3\u51FA\u73B0\u95EE\u9898", 5);
2516
+ message.info(instance.t('刷新token遭到频繁调用,请联系管理员查看是否接口权限出现问题,可能是{{slot0}}接口出现问题', { slot0: response === null || response === void 0 ? void 0 : response.config.url }), 5);
2516
2517
  requestTokenEndTime = 0;
2517
2518
  }
2518
2519
  }
@@ -2560,6 +2561,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2560
2561
  // 刷新成功 重置token 重置refresh-token
2561
2562
  setToken(data === null || data === void 0 ? void 0 : data.access_token);
2562
2563
  setRefreshToken(data === null || data === void 0 ? void 0 : data.refresh_token);
2564
+ message.info(instance.t('token已经刷新成功,请重新提交!', {}));
2563
2565
  onAccessTokenFetched();
2564
2566
  isRefreshing = true;
2565
2567
  }
@@ -2573,7 +2575,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2573
2575
  jumpCallback(401);
2574
2576
  }
2575
2577
  else {
2576
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2578
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2577
2579
  isExpiration = false;
2578
2580
  });
2579
2581
  window.location.href = '/login';
@@ -2589,7 +2591,7 @@ function refreshTokenRequst(jumpCallback, Authorization) {
2589
2591
  jumpCallback(401);
2590
2592
  }
2591
2593
  else {
2592
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2594
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2593
2595
  isExpiration = false;
2594
2596
  });
2595
2597
  window.location.href = '/login';
@@ -2665,7 +2667,11 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2665
2667
  __isTimeoutMessage) {
2666
2668
  isMessage = true;
2667
2669
  Modal.confirm({
2668
- 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),
2670
+ title: instance.t('请求超时,请稍后再试,请去列表确认数据是否插入成功,请勿重复提交! 接口地址:{{slot0}} 请求方式:{{slot1}} 请求超时时间:{{slot2}}', {
2671
+ slot0: (_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.url,
2672
+ slot1: (_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.method,
2673
+ slot2: (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.timeout,
2674
+ }),
2669
2675
  okCancel: false,
2670
2676
  onOk: function () {
2671
2677
  isMessage = false;
@@ -2679,7 +2685,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2679
2685
  if ((errRes === null || errRes === void 0 ? void 0 : errRes.status) === 404) {
2680
2686
  if (!isNotFound) {
2681
2687
  isNotFound = true;
2682
- message.info("\u63A5\u53E3: " + errRes.config.url + " \u672A\u627E\u5230\uFF01", 3.5, function () {
2688
+ message.info(instance.t('接口: {{slot0}} 未找到!', { slot0: errRes.config.url }), 3.5, function () {
2683
2689
  isNotFound = false;
2684
2690
  });
2685
2691
  }
@@ -2695,7 +2701,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2695
2701
  jumpCallback(errRes === null || errRes === void 0 ? void 0 : errRes.status);
2696
2702
  }
2697
2703
  else {
2698
- message.info("\u4F60\u7684\u8D26\u53F7\u5DF2\u5728\u5176\u4ED6\u5730\u65B9\u767B\u5F55\uFF01", 3.5, function () {
2704
+ message.info(instance.t('你的账号已在其他地方登录!', {}), 3.5, function () {
2699
2705
  isOffSite = false;
2700
2706
  });
2701
2707
  window.location.href = '/login';
@@ -2713,7 +2719,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2713
2719
  jumpCallback(errRes === null || errRes === void 0 ? void 0 : errRes.status);
2714
2720
  }
2715
2721
  else {
2716
- message.info("\u767B\u5F55\u8FC7\u671F\uFF01", 3.5, function () {
2722
+ message.info(instance.t('登录过期!', {}), 3.5, function () {
2717
2723
  isExpiration = false;
2718
2724
  });
2719
2725
  window.location.href = '/login';
@@ -2793,6 +2799,8 @@ function request(myOptions, jumpCallback, otherOptions) {
2793
2799
  'Zmdms-Auth': "bearer " + token,
2794
2800
  'Tenant-Id': '000000',
2795
2801
  Authorization: InnerAuthorization ? InnerAuthorization : Authorization,
2802
+ // 设置语言包请求头
2803
+ 'Zmdms-Lang': window.localStorage.getItem('languageType') || 'zh_CN',
2796
2804
  },
2797
2805
  };
2798
2806
  if ((_a = options.baseURL) === null || _a === void 0 ? void 0 : _a.endsWith('/')) {