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.mjs CHANGED
@@ -15997,11 +15997,13 @@ var UniversalExportClient = class {
15997
15997
  * 转换API返回的导出结果
15998
15998
  */
15999
15999
  transformExportResultFromAPI(apiResult) {
16000
+ const fileBlob = this.createFileBlobFromBase64(apiResult.fileData, apiResult.fileName);
16000
16001
  return {
16001
16002
  exportId: apiResult.exportId,
16002
16003
  fileName: apiResult.fileName,
16003
16004
  fileSize: apiResult.fileSize,
16004
16005
  fileUrl: apiResult.fileUrl,
16006
+ fileBlob,
16005
16007
  exportedRows: apiResult.exportedRows,
16006
16008
  startTime: new Date(apiResult.startTime),
16007
16009
  endTime: new Date(apiResult.endTime),
@@ -16009,6 +16011,57 @@ var UniversalExportClient = class {
16009
16011
  statistics: apiResult.statistics
16010
16012
  };
16011
16013
  }
16014
+ /**
16015
+ * 将后端返回的base64文件数据转换为Blob
16016
+ */
16017
+ createFileBlobFromBase64(fileData, fileName) {
16018
+ if (!fileData || typeof fileData !== "string") {
16019
+ return void 0;
16020
+ }
16021
+ try {
16022
+ if (typeof atob === "function") {
16023
+ const binaryString = atob(fileData);
16024
+ const bytes = new Uint8Array(binaryString.length);
16025
+ for (let i = 0; i < binaryString.length; i++) {
16026
+ bytes[i] = binaryString.charCodeAt(i);
16027
+ }
16028
+ const arrayBuffer = bytes.buffer.slice(
16029
+ bytes.byteOffset,
16030
+ bytes.byteOffset + bytes.byteLength
16031
+ );
16032
+ return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
16033
+ } else if (typeof Buffer !== "undefined") {
16034
+ const bufferBytes = Buffer.from(fileData, "base64");
16035
+ const bytes = Uint8Array.from(bufferBytes);
16036
+ const arrayBuffer = bytes.buffer.slice(
16037
+ bytes.byteOffset,
16038
+ bytes.byteOffset + bytes.byteLength
16039
+ );
16040
+ return new Blob([arrayBuffer], { type: this.getMimeTypeByFileName(fileName) });
16041
+ } else {
16042
+ return void 0;
16043
+ }
16044
+ } catch {
16045
+ return void 0;
16046
+ }
16047
+ }
16048
+ /**
16049
+ * 根据文件名推断MIME类型
16050
+ */
16051
+ getMimeTypeByFileName(fileName) {
16052
+ const extension = fileName?.split(".").pop()?.toLowerCase();
16053
+ switch (extension) {
16054
+ case "csv":
16055
+ return "text/csv; charset=utf-8";
16056
+ case "xlsx":
16057
+ case "xls":
16058
+ return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
16059
+ case "json":
16060
+ return "application/json; charset=utf-8";
16061
+ default:
16062
+ return "application/octet-stream";
16063
+ }
16064
+ }
16012
16065
  /**
16013
16066
  * 转换API返回的进度数据
16014
16067
  */