From d175557ab90d16fdc0346a7c278b7a250a4bdbe5 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Thu, 29 Jun 2023 21:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BDbugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/providers/helpers/githubHelper.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/services/providers/helpers/githubHelper.js b/src/services/providers/helpers/githubHelper.js index c5285c6b..777bbce3 100644 --- a/src/services/providers/helpers/githubHelper.js +++ b/src/services/providers/helpers/githubHelper.js @@ -228,13 +228,21 @@ export default { path, isImg, }) { - const { sha, content } = await repoRequest(token, owner, repo, { + const { sha, content, encoding } = await repoRequest(token, owner, repo, { url: `contents/${encodeURIComponent(path)}`, params: { ref: branch }, }); + let tempContent = content; + // 如果是图片且 encoding 为 none 则 需要获取 blob + if (isImg && encoding === 'none') { + const blobInfo = await repoRequest(token, owner, repo, { + url: `git/blobs/${sha}`, + }); + tempContent = blobInfo.content; + } return { sha, - data: !isImg ? utils.decodeBase64(content) : content, + data: !isImg ? utils.decodeBase64(tempContent) : tempContent, }; }, /**