sa2kit 1.6.98 → 1.6.101
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 +61 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -1
- package/dist/index.mjs.map +1 -1
- package/dist/showmasterpiece/index.js +61 -1
- package/dist/showmasterpiece/index.js.map +1 -1
- package/dist/showmasterpiece/index.mjs +61 -1
- package/dist/showmasterpiece/index.mjs.map +1 -1
- package/dist/showmasterpiece/ui/web/index.js +61 -1
- package/dist/showmasterpiece/ui/web/index.js.map +1 -1
- package/dist/showmasterpiece/ui/web/index.mjs +61 -1
- package/dist/showmasterpiece/ui/web/index.mjs.map +1 -1
- package/dist/showmasterpiece/web/index.js +61 -1
- package/dist/showmasterpiece/web/index.js.map +1 -1
- package/dist/showmasterpiece/web/index.mjs +61 -1
- 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 +61 -1
- package/dist/universalExport/index.js.map +1 -1
- package/dist/universalExport/index.mjs +61 -1
- package/dist/universalExport/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -403,7 +403,6 @@ var UniversalExportClient = class {
|
|
|
403
403
|
try {
|
|
404
404
|
const isDataArray = Array.isArray(request.dataSource);
|
|
405
405
|
const requestBody = {
|
|
406
|
-
configId: request.configId,
|
|
407
406
|
queryParams: request.queryParams,
|
|
408
407
|
fieldMapping: request.fieldMapping,
|
|
409
408
|
filters: request.filters,
|
|
@@ -411,6 +410,14 @@ var UniversalExportClient = class {
|
|
|
411
410
|
pagination: request.pagination,
|
|
412
411
|
customFileName: request.customFileName
|
|
413
412
|
};
|
|
413
|
+
if (typeof request.configId === "string") {
|
|
414
|
+
requestBody.configId = request.configId;
|
|
415
|
+
} else {
|
|
416
|
+
requestBody.config = request.configId;
|
|
417
|
+
if (request.configId?.id) {
|
|
418
|
+
requestBody.configId = request.configId.id;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
414
421
|
if (isDataArray) {
|
|
415
422
|
requestBody.data = request.dataSource;
|
|
416
423
|
} else {
|
|
@@ -556,11 +563,13 @@ var UniversalExportClient = class {
|
|
|
556
563
|
* 转换API返回的导出结果
|
|
557
564
|
*/
|
|
558
565
|
transformExportResultFromAPI(apiResult) {
|
|
566
|
+
const fileBlob = this.createFileBlobFromBase64(apiResult.fileData, apiResult.fileName);
|
|
559
567
|
return {
|
|
560
568
|
exportId: apiResult.exportId,
|
|
561
569
|
fileName: apiResult.fileName,
|
|
562
570
|
fileSize: apiResult.fileSize,
|
|
563
571
|
fileUrl: apiResult.fileUrl,
|
|
572
|
+
fileBlob,
|
|
564
573
|
exportedRows: apiResult.exportedRows,
|
|
565
574
|
startTime: new Date(apiResult.startTime),
|
|
566
575
|
endTime: new Date(apiResult.endTime),
|
|
@@ -568,6 +577,57 @@ var UniversalExportClient = class {
|
|
|
568
577
|
statistics: apiResult.statistics
|
|
569
578
|
};
|
|
570
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* 将后端返回的base64文件数据转换为Blob
|
|
582
|
+
*/
|
|
583
|
+
createFileBlobFromBase64(fileData, fileName) {
|
|
584
|
+
if (!fileData || typeof fileData !== "string") {
|
|
585
|
+
return void 0;
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
if (typeof atob === "function") {
|
|
589
|
+
const binaryString = atob(fileData);
|
|
590
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
591
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
592
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
593
|
+
}
|
|
594
|
+
const arrayBuffer = bytes.buffer.slice(
|
|
595
|
+
bytes.byteOffset,
|
|
596
|
+
bytes.byteOffset + bytes.byteLength
|
|
597
|
+
);
|
|
598
|
+
return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
|
|
599
|
+
} else if (typeof Buffer !== "undefined") {
|
|
600
|
+
const bufferBytes = Buffer.from(fileData, "base64");
|
|
601
|
+
const bytes = Uint8Array.from(bufferBytes);
|
|
602
|
+
const arrayBuffer = bytes.buffer.slice(
|
|
603
|
+
bytes.byteOffset,
|
|
604
|
+
bytes.byteOffset + bytes.byteLength
|
|
605
|
+
);
|
|
606
|
+
return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
|
|
607
|
+
} else {
|
|
608
|
+
return void 0;
|
|
609
|
+
}
|
|
610
|
+
} catch {
|
|
611
|
+
return void 0;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* 根据文件名推断MIME类型
|
|
616
|
+
*/
|
|
617
|
+
getMimeTypeByFileName(fileName) {
|
|
618
|
+
const extension = fileName?.split(".").pop()?.toLowerCase();
|
|
619
|
+
switch (extension) {
|
|
620
|
+
case "csv":
|
|
621
|
+
return "text/csv; charset=utf-8";
|
|
622
|
+
case "xlsx":
|
|
623
|
+
case "xls":
|
|
624
|
+
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
625
|
+
case "json":
|
|
626
|
+
return "application/json; charset=utf-8";
|
|
627
|
+
default:
|
|
628
|
+
return "application/octet-stream";
|
|
629
|
+
}
|
|
630
|
+
}
|
|
571
631
|
/**
|
|
572
632
|
* 转换API返回的进度数据
|
|
573
633
|
*/
|