|
|
@@ -2,17 +2,35 @@
|
|
|
* @description: base64 to blob
|
|
|
*/
|
|
|
export function dataURLtoBlob(base64Buf: string): Blob {
|
|
|
+ // 导出专用
|
|
|
const arr = base64Buf.split(',');
|
|
|
- const typeItem = arr[0];
|
|
|
- const mime = typeItem.match(/:(.*?);/)![1];
|
|
|
- const bstr = window.atob(arr[1]);
|
|
|
- let n = bstr.length;
|
|
|
- const u8arr = new Uint8Array(n);
|
|
|
- while (n--) {
|
|
|
- u8arr[n] = bstr.charCodeAt(n);
|
|
|
+ if (arr.length == 1) {
|
|
|
+ const typeItem = arr[0];
|
|
|
+ debugger;
|
|
|
+ // const mime = typeItem.match(/:(.*?);/)![1];
|
|
|
+ const bstr = window.atob(typeItem);
|
|
|
+ let n = bstr.length;
|
|
|
+ const u8arr = new Uint8Array(n);
|
|
|
+ while (n--) {
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
+ }
|
|
|
+ return new Blob([u8arr], {
|
|
|
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const typeItem = arr[0];
|
|
|
+ debugger;
|
|
|
+ const mime = typeItem.match(/:(.*?);/)![1];
|
|
|
+ const bstr = window.atob(arr[1]);
|
|
|
+ let n = bstr.length;
|
|
|
+ const u8arr = new Uint8Array(n);
|
|
|
+ while (n--) {
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
+ }
|
|
|
+ return new Blob([u8arr], { type: mime });
|
|
|
}
|
|
|
- return new Blob([u8arr], { type: mime });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* img url to base64
|
|
|
* @param url
|