ztxkutils 2.10.66-3 → 2.10.66-31
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/businessTools.js +4 -3
- package/dist/{dataModel-1fbaff40.js → dataModel-f1ef06bc.js} +4 -2
- package/dist/dataModel.js +2 -1
- package/dist/fileOperation.d.ts +19 -0
- package/dist/fileOperation.js +60 -18
- package/dist/hooks.js +34 -22
- package/dist/i18next.d.ts +2 -0
- package/dist/i18next.js +2401 -0
- package/dist/index.js +5 -4
- package/dist/myIndexDb.d.ts +1 -1
- package/dist/print.d.ts +2 -4
- package/dist/print.js +3 -2
- package/dist/{reqUrl-22b880a4.js → reqUrl-ea7ef876.js} +3 -2
- package/dist/reqUrl.js +1 -1
- package/dist/{request-87d93572.js → request-40e9ca7b.js} +16 -8
- package/dist/request.js +2 -1
- package/dist/stompClient.js +21 -8
- package/dist/useHistory.js +7 -0
- package/dist/{validate-18e52490.js → validate-2138d94a.js} +29 -15
- package/dist/validate.d.ts +1 -0
- package/dist/validate.js +2 -1
- package/dist/workflow.js +3 -5
- package/locales/en-US.json +64 -0
- package/locales/zh-CN.json +64 -0
- package/package.json +112 -75
- package/zti18n-cli/bin/index.js +3 -0
- package/zti18n-cli/index.js +23 -0
- package/zti18n-cli/src/command/collect.js +353 -0
- package/zti18n-cli/src/command/convert.js +17 -0
- package/zti18n-cli/src/command/convert2.js +35 -0
- package/zti18n-cli/src/command/initFileConf.js +133 -0
- package/zti18n-cli/src/command/publish.js +24 -0
- package/zti18n-cli/src/conf/BaseConf.js +21 -0
- package/zti18n-cli/src/conf/FileConf.js +116 -0
- package/zti18n-cli/src/index.js +75 -0
- package/zti18n-cli/src/translate/google.js +87 -0
- package/zti18n-cli/src/utils/isChinese.js +3 -0
- package/zti18n-cli/src/utils/log.js +8 -0
- package/zti18n-cli/src/utils/mergeOptions.js +45 -0
- package/zti18n-cli/src/utils/reactOptions.js +73 -0
- package/zti18n-cli/src/utils/vueOptions.js +69 -0
- package/zti18n-core/index.js +1 -0
- package/zti18n-core/src/index.js +5 -0
- package/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.js +224 -0
- package/zti18n-core/src/plugin/reactIntlUniversalToDi18n.js +64 -0
- package/zti18n-core/src/transform/defaultPkMap.js +79 -0
- package/zti18n-core/src/transform/transformHtml.js +271 -0
- package/zti18n-core/src/transform/transformJs.js +489 -0
- package/zti18n-core/src/transform/transformPug.js +272 -0
- package/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.js +96 -0
- package/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.js +90 -0
- package/zti18n-core/src/transform/transformToDi18n.js +22 -0
- package/zti18n-core/src/transform/transformTs.js +41 -0
- package/zti18n-core/src/transform/transformVue.js +126 -0
- package/zti18n-core/src/transform/transformZeroToDi18n.js +105 -0
- package/zti18n-core/src/translate/google.js +6 -0
- package/zti18n-core/src/utils/constants.js +3 -0
- package/zti18n-core/src/utils/getIgnoreLines.js +14 -0
- package/zti18n-core/src/utils/isChinese.js +3 -0
- package/zti18n-core/src/utils/log.js +8 -0
- package/dist/request-3c906c2d.js +0 -2913
- package/dist/request-dc69f021.js +0 -2972
- package/dist/tools-16a7fb45.js +0 -2446
package/dist/businessTools.js
CHANGED
@@ -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
|
},
|
@@ -1,16 +1,18 @@
|
|
1
|
+
import instance from './i18next.js';
|
2
|
+
|
1
3
|
/**
|
2
4
|
* @description 数据模型创建
|
3
5
|
*/
|
4
6
|
function createSuccessModel(data, message) {
|
5
7
|
return {
|
6
8
|
data: data,
|
7
|
-
message: message || '数据请求成功',
|
9
|
+
message: message || instance.t('数据请求成功'),
|
8
10
|
success: true,
|
9
11
|
};
|
10
12
|
}
|
11
13
|
function createErrorModel(message) {
|
12
14
|
return {
|
13
|
-
message: message || '数据请求失败',
|
15
|
+
message: message || instance.t('数据请求失败'),
|
14
16
|
success: false,
|
15
17
|
};
|
16
18
|
}
|
package/dist/dataModel.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import './i18next.js';
|
2
|
+
export { a as createErrorModel, c as createSuccessModel } from './dataModel-f1ef06bc.js';
|
package/dist/fileOperation.d.ts
CHANGED
@@ -73,4 +73,23 @@ export declare function createOriginalUrl(fileUrl: string, fileId: string, other
|
|
73
73
|
* @param {string} scale 缩略倍数
|
74
74
|
*/
|
75
75
|
export declare function createThumbnailUrl(apiUrl: string, fileId: string, scale: number, otherOption?: any): string;
|
76
|
+
/**
|
77
|
+
* 附件预览的文件id加密
|
78
|
+
* @param fileId
|
79
|
+
* @returns
|
80
|
+
*/
|
81
|
+
export declare function encodeFileIdByPreview(fileId: string): string;
|
82
|
+
/**
|
83
|
+
* 附件预览的文件id加密
|
84
|
+
* @param fileId
|
85
|
+
* @returns
|
86
|
+
*/
|
87
|
+
export declare function encodeFileIdByDownload(fileId: string): string;
|
88
|
+
/**
|
89
|
+
* 附件预览的文件id加密。加密后只encode一次
|
90
|
+
* 用在那些通过body传参的业务里
|
91
|
+
* @param fileId
|
92
|
+
* @returns
|
93
|
+
*/
|
94
|
+
export declare function encodeOneFileIdByDownload(fileId: string): string;
|
76
95
|
export {};
|
package/dist/fileOperation.js
CHANGED
@@ -11,15 +11,15 @@ import 'crypto';
|
|
11
11
|
*/
|
12
12
|
function downloadFile(apiUrl, fileId, fileName, otherOption) {
|
13
13
|
// 给附件id加密
|
14
|
-
fileId =
|
14
|
+
fileId = encodeFileIdByDownload(fileId);
|
15
15
|
var xhr = new XMLHttpRequest();
|
16
16
|
var token = '';
|
17
|
-
var addWaterMark = '
|
17
|
+
var addWaterMark = 'false';
|
18
18
|
if (typeof otherOption === 'object') {
|
19
19
|
token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
|
20
20
|
addWaterMark = (otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark)
|
21
21
|
? otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark
|
22
|
-
: '
|
22
|
+
: 'false';
|
23
23
|
}
|
24
24
|
else {
|
25
25
|
token = getToken() || otherOption;
|
@@ -27,7 +27,10 @@ function downloadFile(apiUrl, fileId, fileName, otherOption) {
|
|
27
27
|
var _apiUrl = apiUrl.endsWith('/')
|
28
28
|
? apiUrl.slice(0, apiUrl.length - 1)
|
29
29
|
: apiUrl;
|
30
|
-
|
30
|
+
var isLegalWaterMark = typeof addWaterMark === 'boolean' ||
|
31
|
+
addWaterMark === 'true' ||
|
32
|
+
addWaterMark === 'false';
|
33
|
+
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + (isLegalWaterMark ? addWaterMark : false), true);
|
31
34
|
xhr.responseType = 'blob';
|
32
35
|
xhr.onload = function () {
|
33
36
|
if (xhr.status === 200 || xhr.status === 201) {
|
@@ -47,14 +50,17 @@ function downloadFile(apiUrl, fileId, fileName, otherOption) {
|
|
47
50
|
}
|
48
51
|
function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
49
52
|
// 给附件id加密
|
50
|
-
fileId =
|
51
|
-
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError, _b = _a.addWaterMark, addWaterMark = _b === void 0 ?
|
53
|
+
fileId = encodeFileIdByDownload(fileId);
|
54
|
+
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? false : _b;
|
52
55
|
var xhr = new XMLHttpRequest();
|
53
56
|
var token = getToken() || authToken;
|
54
57
|
var _apiUrl = apiUrl.endsWith('/')
|
55
58
|
? apiUrl.slice(0, apiUrl.length - 1)
|
56
59
|
: apiUrl;
|
57
|
-
|
60
|
+
var isLegalWaterMark = typeof addWaterMark === 'boolean' ||
|
61
|
+
addWaterMark === 'true' ||
|
62
|
+
addWaterMark === 'false';
|
63
|
+
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + (isLegalWaterMark ? addWaterMark : false), true);
|
58
64
|
xhr.responseType = 'blob';
|
59
65
|
xhr.onload = function () {
|
60
66
|
if (xhr.status === 200 || xhr.status === 201) {
|
@@ -84,8 +90,8 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
|
84
90
|
*/
|
85
91
|
function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
|
86
92
|
// 给附件id加密
|
87
|
-
fileIds =
|
88
|
-
var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, _b = _a.addWaterMark, addWaterMark = _b === void 0 ?
|
93
|
+
fileIds = encodeFileIdByDownload(fileIds);
|
94
|
+
var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? false : _b, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
89
95
|
var xhr = new XMLHttpRequest();
|
90
96
|
var token = getToken() || authToken;
|
91
97
|
var _apiUrl = apiUrl.endsWith('/')
|
@@ -116,7 +122,14 @@ function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
|
|
116
122
|
};
|
117
123
|
xhr.setRequestHeader('Zmdms-Auth', token || '');
|
118
124
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
119
|
-
|
125
|
+
var isLegalWaterMark = typeof addWaterMark === 'boolean' ||
|
126
|
+
addWaterMark === 'true' ||
|
127
|
+
addWaterMark === 'false';
|
128
|
+
// 不传附件名
|
129
|
+
xhr.send("attachIds=" + fileIds + "&zipName=" + zipName + "&addWaterMark=" + (isLegalWaterMark ? addWaterMark : false));
|
130
|
+
// xhr.send(
|
131
|
+
// `attachIds=${fileIds}&fileNames=${fileNames}&zipName=${zipName}&addWaterMark=${addWaterMark}`
|
132
|
+
// );
|
120
133
|
}
|
121
134
|
/**
|
122
135
|
* @description 公共文件下载,并重命名
|
@@ -164,7 +177,8 @@ function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
|
|
164
177
|
*/
|
165
178
|
function createDownloadUrl(apiUrl, fileId, authToken) {
|
166
179
|
// 给附件id加密
|
167
|
-
fileId = encodeURIComponent(crypto.encrypt(fileId));
|
180
|
+
// fileId = encodeURIComponent(crypto.encrypt(fileId));
|
181
|
+
fileId = encodeFileIdByDownload(fileId);
|
168
182
|
var token = getToken() || authToken;
|
169
183
|
var _apiUrl = apiUrl.endsWith('/')
|
170
184
|
? apiUrl.slice(0, apiUrl.length - 1)
|
@@ -178,7 +192,8 @@ function createDownloadUrl(apiUrl, fileId, authToken) {
|
|
178
192
|
*/
|
179
193
|
function createDownloadUrlNoBase(fileId, authToken) {
|
180
194
|
// 给附件id加密
|
181
|
-
fileId = encodeURIComponent(crypto.encrypt(fileId));
|
195
|
+
// fileId = encodeURIComponent(crypto.encrypt(fileId));
|
196
|
+
fileId = encodeFileIdByDownload(fileId);
|
182
197
|
var token = getToken() || authToken;
|
183
198
|
return "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token;
|
184
199
|
}
|
@@ -203,8 +218,9 @@ function createPublicDownloadUrl(apiUrl, fileId) {
|
|
203
218
|
* @param {string} fileName 文件名
|
204
219
|
*/
|
205
220
|
function previewFile(fileUrl, fileId, otherOption) {
|
221
|
+
var preFileId = fileId;
|
206
222
|
// 给附件id加密
|
207
|
-
fileId =
|
223
|
+
fileId = encodeFileIdByPreview(fileId);
|
208
224
|
var token = '';
|
209
225
|
if (typeof otherOption === 'object') {
|
210
226
|
token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
|
@@ -224,7 +240,7 @@ function previewFile(fileUrl, fileId, otherOption) {
|
|
224
240
|
: fileUrl;
|
225
241
|
if (titleName) {
|
226
242
|
var lastPointIndex = titleName.lastIndexOf('.');
|
227
|
-
var preTitleName = titleName.substring(0, lastPointIndex) + ("-" +
|
243
|
+
var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + preFileId);
|
228
244
|
var suffixTitleName = titleName.substring(lastPointIndex + 1);
|
229
245
|
titleName = suffixTitleName
|
230
246
|
? preTitleName + "." + suffixTitleName
|
@@ -244,7 +260,7 @@ function previewFile(fileUrl, fileId, otherOption) {
|
|
244
260
|
*/
|
245
261
|
function batchPreviewFile(fileUrl, fileId, otherOption) {
|
246
262
|
// 给附件id加密
|
247
|
-
fileId =
|
263
|
+
fileId = encodeFileIdByPreview(fileId);
|
248
264
|
var token = '';
|
249
265
|
if (typeof otherOption === 'object') {
|
250
266
|
token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
|
@@ -276,8 +292,9 @@ function batchPreviewFile(fileUrl, fileId, otherOption) {
|
|
276
292
|
* @param {string} fileType 文件类型
|
277
293
|
*/
|
278
294
|
function createOriginalUrl(fileUrl, fileId, otherOption) {
|
295
|
+
var preFileId = fileId;
|
279
296
|
// 给附件id加密
|
280
|
-
fileId =
|
297
|
+
fileId = encodeFileIdByPreview(fileId);
|
281
298
|
var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
|
282
299
|
var titleName = dangerouslySetXss(otherOption === null || otherOption === void 0 ? void 0 : otherOption.titleName);
|
283
300
|
try {
|
@@ -291,7 +308,7 @@ function createOriginalUrl(fileUrl, fileId, otherOption) {
|
|
291
308
|
: fileUrl;
|
292
309
|
if (titleName) {
|
293
310
|
var lastPointIndex = titleName.lastIndexOf('.');
|
294
|
-
var preTitleName = titleName.substring(0, lastPointIndex) + ("-" +
|
311
|
+
var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + preFileId);
|
295
312
|
var suffixTitleName = titleName.substring(lastPointIndex + 1);
|
296
313
|
titleName = suffixTitleName
|
297
314
|
? preTitleName + "." + suffixTitleName
|
@@ -314,6 +331,31 @@ function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
|
|
314
331
|
: apiUrl;
|
315
332
|
var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
|
316
333
|
return _apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
|
334
|
+
}
|
335
|
+
/**
|
336
|
+
* 附件预览的文件id加密
|
337
|
+
* @param fileId
|
338
|
+
* @returns
|
339
|
+
*/
|
340
|
+
function encodeFileIdByPreview(fileId) {
|
341
|
+
return encodeURIComponent(crypto.encrypt(fileId));
|
342
|
+
}
|
343
|
+
/**
|
344
|
+
* 附件预览的文件id加密
|
345
|
+
* @param fileId
|
346
|
+
* @returns
|
347
|
+
*/
|
348
|
+
function encodeFileIdByDownload(fileId) {
|
349
|
+
return encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
|
350
|
+
}
|
351
|
+
/**
|
352
|
+
* 附件预览的文件id加密。加密后只encode一次
|
353
|
+
* 用在那些通过body传参的业务里
|
354
|
+
* @param fileId
|
355
|
+
* @returns
|
356
|
+
*/
|
357
|
+
function encodeOneFileIdByDownload(fileId) {
|
358
|
+
return encodeURIComponent(crypto.encrypt(fileId));
|
317
359
|
}
|
318
360
|
|
319
|
-
export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
|
361
|
+
export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, previewFile };
|
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: (
|
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
|
-
{
|
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
|
},
|