From c8447fe4f73000b02165912dbde2442df1fb1dd7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 17 Jan 2025 19:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91Bpm=EF=BC=9A=E5=AE=A1=E6=89=B9=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/download.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils/download.ts b/src/utils/download.ts index bd58845f..a2a6b49e 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -66,7 +66,7 @@ const download = { a.click() } }, - base64ToFile: (base64, fileName) => { + base64ToFile: (base64: any, fileName: string) => { // 将base64按照 , 进行分割 将前缀 与后续内容分隔开 const data = base64.split(',') // 利用正则表达式 从前缀中获取图片的类型信息(image/png、image/jpeg、image/webp等) @@ -85,13 +85,11 @@ const download = { // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 u8arr[n] = bstr.charCodeAt(n) } - // 利用构造函数创建File文件对象 - // new File(bits, name, options) - const file = new File([u8arr], `${fileName}.${suffix}`, { + + // 将File文件对象返回给方法的调用者 + return new File([u8arr], `${fileName}.${suffix}`, { type: type }) - // 将File文件对象返回给方法的调用者 - return file } }