sa2kit 1.6.98 → 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.
@@ -7485,11 +7485,13 @@ var UniversalExportClient = class {
7485
7485
  * 转换API返回的导出结果
7486
7486
  */
7487
7487
  transformExportResultFromAPI(apiResult) {
7488
+ const fileBlob = this.createFileBlobFromBase64(apiResult.fileData, apiResult.fileName);
7488
7489
  return {
7489
7490
  exportId: apiResult.exportId,
7490
7491
  fileName: apiResult.fileName,
7491
7492
  fileSize: apiResult.fileSize,
7492
7493
  fileUrl: apiResult.fileUrl,
7494
+ fileBlob,
7493
7495
  exportedRows: apiResult.exportedRows,
7494
7496
  startTime: new Date(apiResult.startTime),
7495
7497
  endTime: new Date(apiResult.endTime),
@@ -7497,6 +7499,57 @@ var UniversalExportClient = class {
7497
7499
  statistics: apiResult.statistics
7498
7500
  };
7499
7501
  }
7502
+ /**
7503
+ * 将后端返回的base64文件数据转换为Blob
7504
+ */
7505
+ createFileBlobFromBase64(fileData, fileName) {
7506
+ if (!fileData || typeof fileData !== "string") {
7507
+ return void 0;
7508
+ }
7509
+ try {
7510
+ if (typeof atob === "function") {
7511
+ const binaryString = atob(fileData);
7512
+ const bytes = new Uint8Array(binaryString.length);
7513
+ for (let i = 0; i < binaryString.length; i++) {
7514
+ bytes[i] = binaryString.charCodeAt(i);
7515
+ }
7516
+ const arrayBuffer = bytes.buffer.slice(
7517
+ bytes.byteOffset,
7518
+ bytes.byteOffset + bytes.byteLength
7519
+ );
7520
+ return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
7521
+ } else if (typeof Buffer !== "undefined") {
7522
+ const bufferBytes = Buffer.from(fileData, "base64");
7523
+ const bytes = Uint8Array.from(bufferBytes);
7524
+ const arrayBuffer = bytes.buffer.slice(
7525
+ bytes.byteOffset,
7526
+ bytes.byteOffset + bytes.byteLength
7527
+ );
7528
+ return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
7529
+ } else {
7530
+ return void 0;
7531
+ }
7532
+ } catch {
7533
+ return void 0;
7534
+ }
7535
+ }
7536
+ /**
7537
+ * 根据文件名推断MIME类型
7538
+ */
7539
+ getMimeTypeByFileName(fileName) {
7540
+ const extension = fileName?.split(".").pop()?.toLowerCase();
7541
+ switch (extension) {
7542
+ case "csv":
7543
+ return "text/csv; charset=utf-8";
7544
+ case "xlsx":
7545
+ case "xls":
7546
+ return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
7547
+ case "json":
7548
+ return "application/json; charset=utf-8";
7549
+ default:
7550
+ return "application/octet-stream";
7551
+ }
7552
+ }
7500
7553
  /**
7501
7554
  * 转换API返回的进度数据
7502
7555
  */