ztxkutils 2.10.66-2 → 2.10.66-21
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/fileOperation.d.ts +19 -0
- package/dist/fileOperation.js +62 -20
- package/dist/i18next.d.ts +2 -0
- package/dist/i18next.js +2380 -0
- package/dist/index.js +2 -2
- package/dist/reqUrl-ea7ef876.js +83 -0
- package/dist/reqUrl.js +1 -1
- package/dist/request-4c29d6de.js +2977 -0
- package/dist/request-588c90ec.js +2976 -0
- package/dist/request.js +1 -1
- package/package.json +41 -4
- package/zti18n-cli/bin/index.js +3 -0
- package/zti18n-cli/index.js +23 -0
- package/zti18n-cli/src/command/collect.js +351 -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 +6 -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 +488 -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/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 公共文件下载,并重命名
|
@@ -126,7 +139,7 @@ function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
|
|
126
139
|
*/
|
127
140
|
function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
|
128
141
|
// 给附件id加密
|
129
|
-
fileId = encodeURIComponent(crypto.encrypt(fileId));
|
142
|
+
// fileId = encodeURIComponent(crypto.encrypt(fileId));
|
130
143
|
var _a = otherOption || {}, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
131
144
|
var xhr = new XMLHttpRequest();
|
132
145
|
var _apiUrl = apiUrl.endsWith('/')
|
@@ -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
|
}
|
@@ -189,7 +204,7 @@ function createDownloadUrlNoBase(fileId, authToken) {
|
|
189
204
|
*/
|
190
205
|
function createPublicDownloadUrl(apiUrl, fileId) {
|
191
206
|
// 给附件id加密
|
192
|
-
fileId = encodeURIComponent(crypto.encrypt(fileId));
|
207
|
+
// fileId = encodeURIComponent(crypto.encrypt(fileId));
|
193
208
|
var _apiUrl = apiUrl.endsWith('/')
|
194
209
|
? apiUrl.slice(0, apiUrl.length - 1)
|
195
210
|
: apiUrl;
|
@@ -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 };
|