From 27ebd2e8cf9592535779b83740cd94f809ebd668 Mon Sep 17 00:00:00 2001 From: ZongLiang <649236041@qq.com> Date: Thu, 27 Feb 2025 09:57:34 +0800 Subject: [PATCH] Update parseOffice.ts (#3901) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新本地导入pptx文件提示文件编码错误 The argument 'windows-1252' is invalid encoding. Received 'encoding' --- packages/service/worker/readFile/parseOffice.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/service/worker/readFile/parseOffice.ts b/packages/service/worker/readFile/parseOffice.ts index 177f5e2cd..a6a7c8c59 100644 --- a/packages/service/worker/readFile/parseOffice.ts +++ b/packages/service/worker/readFile/parseOffice.ts @@ -46,11 +46,9 @@ const parsePowerPoint = async ({ // Returning an array of all the xml contents read using fs.readFileSync const xmlContentArray = await Promise.all( files.map((file) => { - try { - return fs.promises.readFile(`${decompressPath}/${file.path}`, encoding); - } catch (err) { + return fs.promises.readFile(`${decompressPath}/${file.path}`, encoding).catch(() => { return fs.promises.readFile(`${decompressPath}/${file.path}`, 'utf-8'); - } + }); }) );