zmdms-utils 0.0.78 → 0.0.80
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/es/file.d.ts +1 -0
- package/dist/es/file.js +7 -4
- package/dist/es/math.js +5 -1
- package/package.json +1 -1
- package/src/file.ts +8 -3
- package/src/math.ts +7 -1
package/dist/es/file.d.ts
CHANGED
package/dist/es/file.js
CHANGED
|
@@ -272,8 +272,8 @@ function createDownloadLink(fileId, options) {
|
|
|
272
272
|
*/
|
|
273
273
|
function createOriginalLink(fileId, fileName, options) {
|
|
274
274
|
if (options === void 0) { options = {}; }
|
|
275
|
-
var API_BASEURL = options.API_BASEURL, authToken = options.authToken;
|
|
276
|
-
var
|
|
275
|
+
var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.encodeNum, encodeNum = _a === void 0 ? 1 : _a;
|
|
276
|
+
var _b = getBasicInfo(FILE_PRVIEW_SERVICE_URL || API_BASEURL || "", authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
|
|
277
277
|
// 处理附件名中的一些特殊字符
|
|
278
278
|
var previewFileName = dangerouslyXss(fileName);
|
|
279
279
|
try {
|
|
@@ -283,7 +283,7 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
283
283
|
console.log(err);
|
|
284
284
|
}
|
|
285
285
|
// 获取文件后缀
|
|
286
|
-
var
|
|
286
|
+
var _c = getFileExtension(previewFileName), filePreName = _c[0], fileExtension = _c[1];
|
|
287
287
|
// 由于预览使用了文件名地址作为iframe的路径
|
|
288
288
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
289
289
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
@@ -293,7 +293,7 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
293
293
|
return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/attach/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
|
|
294
294
|
}
|
|
295
295
|
if (isZmdmsFileService) {
|
|
296
|
-
fileId = encodeFileId(fileId,
|
|
296
|
+
fileId = encodeFileId(fileId, encodeNum);
|
|
297
297
|
}
|
|
298
298
|
return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
|
|
299
299
|
(fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
|
|
@@ -364,6 +364,9 @@ function getBasicInfo(baseURL, token) {
|
|
|
364
364
|
function encodeFileId(fileId, encodeNum) {
|
|
365
365
|
if (encodeNum === void 0) { encodeNum = 1; }
|
|
366
366
|
var crypto = new Crypto(window.__CRYPTO_AES_KEY__, window.__CRYPTO_DES_KEY__);
|
|
367
|
+
if (encodeNum === 0) {
|
|
368
|
+
return crypto.encrypt(fileId);
|
|
369
|
+
}
|
|
367
370
|
if (encodeNum === 1) {
|
|
368
371
|
return encodeURIComponent(crypto.encrypt(fileId));
|
|
369
372
|
}
|
package/dist/es/math.js
CHANGED
|
@@ -115,7 +115,11 @@ function exactRound(num, ratio) {
|
|
|
115
115
|
}
|
|
116
116
|
var value = new Decimal(num).toFixed(ratio);
|
|
117
117
|
// 设置exactRound去掉小数位后面的0
|
|
118
|
-
|
|
118
|
+
var exactRoundType = window.__EXACT_ROUND_TYPE__;
|
|
119
|
+
var exactRoundTypePrecision = window
|
|
120
|
+
.__EXACT_ROUND_TYPE_PRECISION__;
|
|
121
|
+
if (exactRoundType === "TRIM_ZEROS" &&
|
|
122
|
+
(exactRoundTypePrecision || ratio) === ratio) {
|
|
119
123
|
value = Number(value);
|
|
120
124
|
}
|
|
121
125
|
return value;
|
package/package.json
CHANGED
package/src/file.ts
CHANGED
|
@@ -337,7 +337,7 @@ export function createOriginalLink(
|
|
|
337
337
|
fileName: string,
|
|
338
338
|
options: IOriginLinkOptions = {}
|
|
339
339
|
) {
|
|
340
|
-
const { API_BASEURL, authToken } = options;
|
|
340
|
+
const { API_BASEURL, authToken, encodeNum = 1 } = options;
|
|
341
341
|
const { token, apiBaseURL } = getBasicInfo(
|
|
342
342
|
FILE_PRVIEW_SERVICE_URL || API_BASEURL || "",
|
|
343
343
|
authToken
|
|
@@ -360,7 +360,7 @@ export function createOriginalLink(
|
|
|
360
360
|
return `${apiBaseURL}/api/${BASIC_KEY}-resource/attach/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`;
|
|
361
361
|
}
|
|
362
362
|
if (isZmdmsFileService) {
|
|
363
|
-
fileId = encodeFileId(fileId,
|
|
363
|
+
fileId = encodeFileId(fileId, encodeNum);
|
|
364
364
|
}
|
|
365
365
|
return (
|
|
366
366
|
`${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
|
|
@@ -456,7 +456,9 @@ interface IPreviewOptions extends IOptions {
|
|
|
456
456
|
[props: string]: string;
|
|
457
457
|
}[];
|
|
458
458
|
}
|
|
459
|
-
interface IOriginLinkOptions extends Partial<IOptions> {
|
|
459
|
+
interface IOriginLinkOptions extends Partial<IOptions> {
|
|
460
|
+
encodeNum?: number;
|
|
461
|
+
}
|
|
460
462
|
interface IThumbnailLinkOptions extends Partial<IOptions> {
|
|
461
463
|
/** 缩放比例 */
|
|
462
464
|
scale?: number;
|
|
@@ -475,6 +477,9 @@ export function encodeFileId(fileId: string, encodeNum: number = 1) {
|
|
|
475
477
|
(window as any).__CRYPTO_AES_KEY__,
|
|
476
478
|
(window as any).__CRYPTO_DES_KEY__
|
|
477
479
|
);
|
|
480
|
+
if (encodeNum === 0) {
|
|
481
|
+
return crypto.encrypt(fileId);
|
|
482
|
+
}
|
|
478
483
|
if (encodeNum === 1) {
|
|
479
484
|
return encodeURIComponent(crypto.encrypt(fileId));
|
|
480
485
|
}
|
package/src/math.ts
CHANGED
|
@@ -115,7 +115,13 @@ export function exactRound(num: numType, ratio: number) {
|
|
|
115
115
|
}
|
|
116
116
|
let value: numType = new Decimal(num).toFixed(ratio);
|
|
117
117
|
// 设置exactRound去掉小数位后面的0
|
|
118
|
-
|
|
118
|
+
const exactRoundType = (window as any).__EXACT_ROUND_TYPE__;
|
|
119
|
+
const exactRoundTypePrecision = (window as any)
|
|
120
|
+
.__EXACT_ROUND_TYPE_PRECISION__;
|
|
121
|
+
if (
|
|
122
|
+
exactRoundType === "TRIM_ZEROS" &&
|
|
123
|
+
(exactRoundTypePrecision || ratio) === ratio
|
|
124
|
+
) {
|
|
119
125
|
value = Number(value);
|
|
120
126
|
}
|
|
121
127
|
return value;
|