sa2kit 1.6.97 → 1.6.100
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/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -0
- package/dist/index.mjs.map +1 -1
- package/dist/showmasterpiece/index.js +53 -0
- package/dist/showmasterpiece/index.js.map +1 -1
- package/dist/showmasterpiece/index.mjs +53 -0
- package/dist/showmasterpiece/index.mjs.map +1 -1
- package/dist/showmasterpiece/ui/web/index.js +53 -0
- package/dist/showmasterpiece/ui/web/index.js.map +1 -1
- package/dist/showmasterpiece/ui/web/index.mjs +53 -0
- package/dist/showmasterpiece/ui/web/index.mjs.map +1 -1
- package/dist/showmasterpiece/web/index.js +53 -0
- package/dist/showmasterpiece/web/index.js.map +1 -1
- package/dist/showmasterpiece/web/index.mjs +53 -0
- package/dist/showmasterpiece/web/index.mjs.map +1 -1
- package/dist/universalExport/index.d.mts +8 -0
- package/dist/universalExport/index.d.ts +8 -0
- package/dist/universalExport/index.js +53 -0
- package/dist/universalExport/index.js.map +1 -1
- package/dist/universalExport/index.mjs +53 -0
- package/dist/universalExport/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -72,6 +72,14 @@ declare class UniversalExportClient {
|
|
|
72
72
|
* 转换API返回的导出结果
|
|
73
73
|
*/
|
|
74
74
|
private transformExportResultFromAPI;
|
|
75
|
+
/**
|
|
76
|
+
* 将后端返回的base64文件数据转换为Blob
|
|
77
|
+
*/
|
|
78
|
+
private createFileBlobFromBase64;
|
|
79
|
+
/**
|
|
80
|
+
* 根据文件名推断MIME类型
|
|
81
|
+
*/
|
|
82
|
+
private getMimeTypeByFileName;
|
|
75
83
|
/**
|
|
76
84
|
* 转换API返回的进度数据
|
|
77
85
|
*/
|
|
@@ -72,6 +72,14 @@ declare class UniversalExportClient {
|
|
|
72
72
|
* 转换API返回的导出结果
|
|
73
73
|
*/
|
|
74
74
|
private transformExportResultFromAPI;
|
|
75
|
+
/**
|
|
76
|
+
* 将后端返回的base64文件数据转换为Blob
|
|
77
|
+
*/
|
|
78
|
+
private createFileBlobFromBase64;
|
|
79
|
+
/**
|
|
80
|
+
* 根据文件名推断MIME类型
|
|
81
|
+
*/
|
|
82
|
+
private getMimeTypeByFileName;
|
|
75
83
|
/**
|
|
76
84
|
* 转换API返回的进度数据
|
|
77
85
|
*/
|
|
@@ -562,11 +562,13 @@ var UniversalExportClient = class {
|
|
|
562
562
|
* 转换API返回的导出结果
|
|
563
563
|
*/
|
|
564
564
|
transformExportResultFromAPI(apiResult) {
|
|
565
|
+
const fileBlob = this.createFileBlobFromBase64(apiResult.fileData, apiResult.fileName);
|
|
565
566
|
return {
|
|
566
567
|
exportId: apiResult.exportId,
|
|
567
568
|
fileName: apiResult.fileName,
|
|
568
569
|
fileSize: apiResult.fileSize,
|
|
569
570
|
fileUrl: apiResult.fileUrl,
|
|
571
|
+
fileBlob,
|
|
570
572
|
exportedRows: apiResult.exportedRows,
|
|
571
573
|
startTime: new Date(apiResult.startTime),
|
|
572
574
|
endTime: new Date(apiResult.endTime),
|
|
@@ -574,6 +576,57 @@ var UniversalExportClient = class {
|
|
|
574
576
|
statistics: apiResult.statistics
|
|
575
577
|
};
|
|
576
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* 将后端返回的base64文件数据转换为Blob
|
|
581
|
+
*/
|
|
582
|
+
createFileBlobFromBase64(fileData, fileName) {
|
|
583
|
+
if (!fileData || typeof fileData !== "string") {
|
|
584
|
+
return void 0;
|
|
585
|
+
}
|
|
586
|
+
try {
|
|
587
|
+
if (typeof atob === "function") {
|
|
588
|
+
const binaryString = atob(fileData);
|
|
589
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
590
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
591
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
592
|
+
}
|
|
593
|
+
const arrayBuffer = bytes.buffer.slice(
|
|
594
|
+
bytes.byteOffset,
|
|
595
|
+
bytes.byteOffset + bytes.byteLength
|
|
596
|
+
);
|
|
597
|
+
return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
|
|
598
|
+
} else if (typeof Buffer !== "undefined") {
|
|
599
|
+
const bufferBytes = Buffer.from(fileData, "base64");
|
|
600
|
+
const bytes = Uint8Array.from(bufferBytes);
|
|
601
|
+
const arrayBuffer = bytes.buffer.slice(
|
|
602
|
+
bytes.byteOffset,
|
|
603
|
+
bytes.byteOffset + bytes.byteLength
|
|
604
|
+
);
|
|
605
|
+
return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
|
|
606
|
+
} else {
|
|
607
|
+
return void 0;
|
|
608
|
+
}
|
|
609
|
+
} catch {
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* 根据文件名推断MIME类型
|
|
615
|
+
*/
|
|
616
|
+
getMimeTypeByFileName(fileName) {
|
|
617
|
+
const extension = fileName?.split(".").pop()?.toLowerCase();
|
|
618
|
+
switch (extension) {
|
|
619
|
+
case "csv":
|
|
620
|
+
return "text/csv; charset=utf-8";
|
|
621
|
+
case "xlsx":
|
|
622
|
+
case "xls":
|
|
623
|
+
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
624
|
+
case "json":
|
|
625
|
+
return "application/json; charset=utf-8";
|
|
626
|
+
default:
|
|
627
|
+
return "application/octet-stream";
|
|
628
|
+
}
|
|
629
|
+
}
|
|
577
630
|
/**
|
|
578
631
|
* 转换API返回的进度数据
|
|
579
632
|
*/
|