ztxkutils 2.10.66-25 → 2.10.66-26

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.
@@ -1,3 +1,4 @@
1
+ import instance from './i18next.js';
1
2
  import { Modal } from 'ztxkui';
2
3
 
3
4
  /**
@@ -6,9 +7,9 @@ import { Modal } from 'ztxkui';
6
7
  function openTipModal(callback, options) {
7
8
  if (options && options.showModal) {
8
9
  Modal.confirm({
9
- content: options.tipTitle || '切换将清空已选数据!',
10
- okText: '确认',
11
- cancelText: '取消',
10
+ content: options.tipTitle || instance.t('切换将清空已选数据!'),
11
+ okText: instance.t('确认'),
12
+ cancelText: instance.t('取消'),
12
13
  onCancel: function () {
13
14
  callback && callback(false);
14
15
  },
@@ -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 +1,2 @@
1
- export { a as createErrorModel, c as createSuccessModel } from './dataModel-1fbaff40.js';
1
+ import './i18next.js';
2
+ export { a as createErrorModel, c as createSuccessModel } from './dataModel-914b6226.js';
package/dist/hooks.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { _ as __assign, b as __awaiter, c as __generator } from './tslib.es6-35653116.js';
2
2
  import { useState, useEffect, useRef, useCallback } from 'react';
3
+ import instance from './i18next.js';
3
4
  export { default as useFileIdToBase64 } from './useFileIdToBase64.js';
4
5
  import { message } from 'ztxkui';
5
6
  import axios from 'axios';
@@ -136,7 +137,12 @@ function useTableValidate(records, columns, tableName, expandProps) {
136
137
  return [4 /*yield*/, Promise.reject({
137
138
  errorFields: [
138
139
  {
139
- errors: (tableName || '') + " \u7B2C" + (i + 1) + "\u884C" + title + " " + (validate.message || '填写错误!'),
140
+ errors: instance.t('{{slot0}} 第{{slot1}}行{{title}} {{slot2}}', {
141
+ slot0: tableName || '',
142
+ slot1: i + 1,
143
+ title: title,
144
+ slot2: validate.message || '填写错误!',
145
+ }),
140
146
  },
141
147
  ],
142
148
  })];
@@ -148,7 +154,13 @@ function useTableValidate(records, columns, tableName, expandProps) {
148
154
  if (!(item[key] === '' || item[key] == null)) return [3 /*break*/, 9];
149
155
  return [4 /*yield*/, Promise.reject({
150
156
  errorFields: [
151
- { errors: (tableName || '') + " \u7B2C" + (i + 1) + "\u884C" + title + "\u4E3A\u7A7A!" },
157
+ {
158
+ errors: instance.t('{{slot0}} 第{{slot1}}行{{title}}为空!', {
159
+ slot0: tableName || '',
160
+ slot1: i + 1,
161
+ title: title,
162
+ }),
163
+ },
152
164
  ],
153
165
  })];
154
166
  case 8:
@@ -432,7 +444,7 @@ function useWs(info) {
432
444
  // 获取讯飞WS长连接地址
433
445
  var getWebSocketUrlHandle = useCallback(function () {
434
446
  if (!getWsUrlRequest) {
435
- throw new Error('必须传入获取Ws长连接的方法');
447
+ throw new Error(instance.t('必须传入获取Ws长连接的方法'));
436
448
  }
437
449
  return new Promise(function (resolve, reject) {
438
450
  getWsUrlRequest()
@@ -443,12 +455,12 @@ function useWs(info) {
443
455
  resolve(websocketUrlRef.current);
444
456
  }
445
457
  else {
446
- reject({ msg: '获取ws链接地址失败!' });
458
+ reject({ msg: instance.t('获取ws链接地址失败!') });
447
459
  }
448
460
  })
449
461
  .catch(function (err) {
450
462
  var _a;
451
- reject({ msg: ((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.msg) || '获取ws地址失败!' });
463
+ reject({ msg: ((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.msg) || instance.t('获取ws地址失败!') });
452
464
  });
453
465
  });
454
466
  }, []);
@@ -476,14 +488,14 @@ function useWs(info) {
476
488
  }
477
489
  else {
478
490
  changeStatus('CLOSED');
479
- message.info(((_a = res) === null || _a === void 0 ? void 0 : _a.msg) || '获取ws地址失败!');
491
+ message.info(((_a = res) === null || _a === void 0 ? void 0 : _a.msg) || instance.t('获取ws地址失败!'));
480
492
  return [2 /*return*/];
481
493
  }
482
494
  return [3 /*break*/, 4];
483
495
  case 3:
484
496
  err_1 = _b.sent();
485
497
  changeStatus('CLOSED');
486
- message.info((err_1 === null || err_1 === void 0 ? void 0 : err_1.msg) || '获取ws地址失败!');
498
+ message.info((err_1 === null || err_1 === void 0 ? void 0 : err_1.msg) || instance.t('获取ws地址失败!'));
487
499
  return [2 /*return*/];
488
500
  case 4:
489
501
  // 长连接不能复用? 发送完 end: true后 长连接就关闭了
@@ -496,14 +508,14 @@ function useWs(info) {
496
508
  webscoketObjRef.current = new window.MozWebSocket(websocketUrl);
497
509
  }
498
510
  else {
499
- message.info('浏览器不支持WebSocket');
511
+ message.info(instance.t('浏览器不支持WebSocket'));
500
512
  return [2 /*return*/];
501
513
  }
502
514
  // SETP 3 监听WS长连接的各种状态
503
515
  // 连接建立开始后。开始录音
504
516
  webscoketObjRef.current.onopen = function (e) {
505
517
  if (isDebugger) {
506
- console.log('连接建立', e);
518
+ console.log(instance.t('连接建立'), e);
507
519
  }
508
520
  resultTextRef.current = '';
509
521
  textResultCbLastest.current &&
@@ -515,7 +527,7 @@ function useWs(info) {
515
527
  parseWsData(e.data, function (msg) {
516
528
  if (msg.code === '0') {
517
529
  if (isDebugger) {
518
- console.log('识别结果:', msg.resultText);
530
+ console.log(instance.t('识别结果:'), msg.resultText);
519
531
  }
520
532
  resultTextRef.current += msg.resultText;
521
533
  textResultCbLastest.current &&
@@ -525,7 +537,7 @@ function useWs(info) {
525
537
  var _a, _b;
526
538
  if (err) {
527
539
  if (isDebugger) {
528
- console.log('ws连接出错了!');
540
+ console.log(instance.t('ws连接出错了!'));
529
541
  }
530
542
  recorder.stop();
531
543
  webscoketObjRef.current.send('{"end": true}');
@@ -539,7 +551,7 @@ function useWs(info) {
539
551
  // 修改状态为 CLOSED
540
552
  webscoketObjRef.current.onerror = function (e) {
541
553
  if (isDebugger) {
542
- console.log('连接异常', e);
554
+ console.log(instance.t('连接异常'), e);
543
555
  }
544
556
  recorder.stop();
545
557
  changeStatus('CLOSED');
@@ -549,7 +561,7 @@ function useWs(info) {
549
561
  // 修改状态为 CLOSED
550
562
  webscoketObjRef.current.onclose = function (e) {
551
563
  if (isDebugger) {
552
- console.log('连接关闭', e);
564
+ console.log(instance.t('连接关闭'), e);
553
565
  }
554
566
  recorder.stop();
555
567
  changeStatus('CLOSED');
@@ -593,7 +605,7 @@ function useRecorderManager(options) {
593
605
  };
594
606
  }
595
607
  if (!RecorderManager) {
596
- console.error('你没有引入路由相关API,请引入!');
608
+ console.error(instance.t('你没有引入路由相关API,请引入!'));
597
609
  }
598
610
  var start = function () { return __awaiter(_this, void 0, void 0, function () {
599
611
  var _a, _b;
@@ -626,13 +638,13 @@ function parseWsData(data, msgCallback, callback, isDebugger) {
626
638
  if (jsonData.action === 'started') {
627
639
  // 握手成功
628
640
  if (isDebugger) {
629
- console.log('握手成功');
641
+ console.log(instance.t('握手成功'));
630
642
  }
631
643
  }
632
644
  else if (jsonData.action === 'result') {
633
645
  var data_1 = JSON.parse(jsonData.data);
634
646
  if (isDebugger) {
635
- console.log('收到讯飞的语音提示', data_1);
647
+ console.log(instance.t('收到讯飞的语音提示'), data_1);
636
648
  }
637
649
  // 类型是 '0' 的话 表示是完整的音频
638
650
  // 类型是 '1' 的话 表示是中间的音频
@@ -656,9 +668,9 @@ function parseWsData(data, msgCallback, callback, isDebugger) {
656
668
  else if (jsonData.action === 'error') {
657
669
  // 连接发生错误
658
670
  if (isDebugger) {
659
- console.log('出错了:', jsonData);
671
+ console.log(instance.t('出错了:'), jsonData);
660
672
  }
661
- callback({ code: '1', msg: '连接出错了' });
673
+ callback({ code: '1', msg: instance.t('连接出错了') });
662
674
  }
663
675
  }
664
676
  catch (err) {
@@ -708,7 +720,7 @@ function useStartWs(info) {
708
720
  webscoketObj.send(new Int8Array(frameBuffer));
709
721
  if (isLastFrame) {
710
722
  if (isDebugger) {
711
- console.log('收到录音的最后帧!');
723
+ console.log(instance.t('收到录音的最后帧!'));
712
724
  }
713
725
  webscoketObj.send('{"end": true}');
714
726
  // 最后一段录音结束才可以结束翻译
@@ -725,7 +737,7 @@ function useStartWs(info) {
725
737
  statusLastest.current === 'CLOSED' &&
726
738
  isNeedCmd) {
727
739
  if (!getWsCmdRequest) {
728
- throw new Error('你没有传入 获取指令的接口,这将导致错误!');
740
+ throw new Error(instance.t('你没有传入 获取指令的接口,这将导致错误!'));
729
741
  }
730
742
  if (cancelRef.current) {
731
743
  cancelRef.current();
@@ -741,12 +753,12 @@ function useStartWs(info) {
741
753
  cbLastest.current && cbLastest.current(res.data.data);
742
754
  }
743
755
  else {
744
- message.error(((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || '不支持处理该指令,请重说!');
756
+ message.error(((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || instance.t('不支持处理该指令,请重说!'));
745
757
  }
746
758
  })
747
759
  .catch(function (err) {
748
760
  var _a, _b;
749
- message.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || '不支持处理该指令,请重说!');
761
+ message.error(((_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || instance.t('不支持处理该指令,请重说!'));
750
762
  });
751
763
  }
752
764
  },
package/dist/i18next.js CHANGED
@@ -2377,4 +2377,24 @@ instance.hasLoadedNamespace;
2377
2377
  instance.loadNamespaces;
2378
2378
  instance.loadLanguages;
2379
2379
 
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
+ return result || args[0];
2395
+ };
2396
+ },
2397
+ });
2398
+ instance.t = t;
2399
+
2380
2400
  export default instance;
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export { d as authority } from './authority-7a91cb9f.js';
2
- export { d as dataModel } from './dataModel-1fbaff40.js';
2
+ export { d as dataModel } from './dataModel-914b6226.js';
3
3
  export { t as tools } from './tools-390e3466.js';
4
- export { v as validate } from './validate-18e52490.js';
5
- export { r as request } from './request-4c29d6de.js';
4
+ export { v as validate } from './validate-2de5a28f.js';
5
+ export { r as request } from './request-1e442d5d.js';
6
6
  export { r as reqUrl } from './reqUrl-ea7ef876.js';
7
+ import './i18next.js';
7
8
  import './tslib.es6-35653116.js';
8
9
  import 'dayjs';
9
10
  import 'axios';
@@ -1 +1 @@
1
- declare function openDB(dbName: string, version?: number): Promise<unknown>;
1
+ export {};
package/dist/print.d.ts CHANGED
@@ -66,10 +66,8 @@ export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, file
66
66
  pdfName?: string;
67
67
  isDownload?: boolean;
68
68
  pdfOption?: IPdfOption;
69
- /** 是否添加水印 */
70
- isAddWater?: boolean;
71
- /** 水印base 64字符串 */
72
- waterBase64?: string;
69
+ /** 是否添加水印 */ isAddWater?: boolean;
70
+ /** 水印base 64字符串 */ waterBase64?: string;
73
71
  imgWidth?: number;
74
72
  imgHeight?: number;
75
73
  isCompress?: boolean;
package/dist/print.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { d as __spreadArray, _ as __assign, b as __awaiter, c as __generator } from './tslib.es6-35653116.js';
2
+ import instance from './i18next.js';
2
3
  import { jsPDF } from 'jspdf';
3
4
  import html2canvas from 'html2canvas';
4
5
 
@@ -74,7 +75,7 @@ function createWaterHandle(obj) {
74
75
  // console.log(err);
75
76
  // }
76
77
  // }
77
- var defaultWaterText = '浙商中拓';
78
+ var defaultWaterText = instance.t('浙商中拓');
78
79
  var _a = obj || {}, waterText = _a.waterText, opacity = _a.opacity, fontSize = _a.fontSize, cavansWidth = _a.cavansWidth, cavansHeight = _a.cavansHeight;
79
80
  var canvas = document.createElement('canvas');
80
81
  var defaultCanvasWidth = waterText
@@ -92,7 +93,7 @@ function createWaterHandle(obj) {
92
93
  var ctx = canvas.getContext('2d');
93
94
  if (ctx) {
94
95
  ctx.rotate((-10 * Math.PI) / 180); // 水印旋转角度
95
- ctx.font = (fontSize || '18px') + " \u5FAE\u8F6F\u96C5\u9ED1";
96
+ ctx.font = instance.t('{{slot0}} 微软雅黑', { slot0: fontSize || '18px' });
96
97
  ctx.fillStyle = "rgba(0,0,0," + (opacity ? opacity : '0.07') + ")";
97
98
  ctx.textAlign = 'center';
98
99
  ctx.textBaseline = 'middle';
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @file 项目基本配置,包括各个环境的请求地址
3
+ */
4
+ // 环境变量
5
+ function getReqUrl(processObj) {
6
+ var ENV = processObj.REACT_APP_ENV;
7
+ // api服务器各个环境地址
8
+ var ZT_API_DEV = processObj.REACT_APP_ZT_API_DEV || window.location.origin; // 开发环境
9
+ var ZT_API_TEST = processObj.REACT_APP_ZT_API_TEST || window.location.origin; // 测试环境 https://192.168.0.135:8000
10
+ var ZT_API_STAGE = processObj.REACT_APP_ZT_API_STAGE || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
11
+ var ZT_API_SIM = processObj.REACT_APP_ZT_API_SIM || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
12
+ var ZT_API_PRODUCT = processObj.REACT_APP_ZT_API_PRODUCT || window.location.origin; // 生产环境 http://dz.zmd.com.cn
13
+ var ZT_API_PUBLIC_PRODUCT = processObj.REACT_APP_ZT_API_PUBLIC_PRODUCT ||
14
+ 'https://nportal.zmd.com.cn:18998'; // 生产环境外网api地址 https://m-portal.zmd.com.cn:18998 http://dz.zmd.com.cn:48000
15
+ // 文件服务器
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 || 'http://172.55.5.101:33013'; // 测试环境 https://192.168.0.135:18012
18
+ var ZT_FILE_PREVIEW_STAGE = processObj.REACT_APP_ZT_FILE_PREVIEW_STAGE ||
19
+ 'https://dzfile-prod.zmd.com.cn/'; // 阶段性环境 http://192.168.0.134:8012
20
+ var ZT_FILE_PREVIEW_SIM = processObj.REACT_APP_ZT_FILE_PREVIEW_SIM ||
21
+ 'https://dzfile-data.zmd.com.cn/'; // 阶段性环境 http://192.168.0.134:8012
22
+ var ZT_FILE_PREVIEW_PRODUCT = processObj.REACT_APP_ZT_FILE_PREVIEW_PRODUCT ||
23
+ 'https://dzfile.zmd.com.cn:8012'; // 生产环境
24
+ // 字体文件附件id
25
+ var ZT_FONTFAMILY_DEV = '1551733945007517697';
26
+ var ZT_FONTFAMILY_TEST = '1551836774183047169';
27
+ var ZT_FONTFAMILY_STAGE = '1551837561144905730';
28
+ var ZT_FONTFAMILY_SIM = '1562010976138207234';
29
+ var ZT_FONTFAMILY_PRODUCT = '1552851055372992513';
30
+ // 实际api请求地址
31
+ var ZT_API_BASEURL = ZT_API_DEV;
32
+ var ZT_API_PUBLICURL = ZT_API_PUBLIC_PRODUCT;
33
+ var ZT_FILE_BASEURL = ZT_FILE_PREVIEW_DEV;
34
+ var ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_DEV;
35
+ if (ENV) {
36
+ switch (ENV.toLowerCase()) {
37
+ case 'zt-dev':
38
+ ZT_API_BASEURL = ZT_API_DEV;
39
+ ZT_API_PUBLICURL = ZT_API_DEV;
40
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_DEV;
41
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_DEV;
42
+ break;
43
+ case 'zt-test':
44
+ ZT_API_BASEURL = ZT_API_TEST;
45
+ ZT_API_PUBLICURL = ZT_API_TEST;
46
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_TEST;
47
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_TEST;
48
+ break;
49
+ case 'zt-stage':
50
+ ZT_API_BASEURL = ZT_API_STAGE;
51
+ ZT_API_PUBLICURL = ZT_API_STAGE;
52
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_STAGE;
53
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_STAGE;
54
+ break;
55
+ case 'zt-sim':
56
+ ZT_API_BASEURL = ZT_API_SIM;
57
+ ZT_API_PUBLICURL = ZT_API_SIM;
58
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_SIM;
59
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_SIM;
60
+ break;
61
+ case 'zt-product':
62
+ ZT_API_BASEURL = ZT_API_PRODUCT;
63
+ ZT_API_PUBLICURL = ZT_API_PUBLIC_PRODUCT;
64
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_PRODUCT;
65
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_PRODUCT;
66
+ break;
67
+ }
68
+ }
69
+ return {
70
+ ZT_API_BASEURL: ZT_API_BASEURL,
71
+ ZT_FILE_BASEURL: ZT_FILE_BASEURL,
72
+ ZT_API_PUBLICURL: ZT_API_PUBLICURL,
73
+ ZT_FONTFAMILY_BASEURL: ZT_FONTFAMILY_BASEURL,
74
+ };
75
+ }
76
+
77
+ var reqUrl = /*#__PURE__*/Object.freeze({
78
+ __proto__: null,
79
+ getReqUrl: getReqUrl
80
+ });
81
+
82
+ export { getReqUrl as g, reqUrl as r };