图片加载bugfix

This commit is contained in:
xiaoqi.cxq 2023-06-29 21:49:16 +08:00
parent 8e12eaebd2
commit d175557ab9

View File

@ -228,13 +228,21 @@ export default {
path, path,
isImg, isImg,
}) { }) {
const { sha, content } = await repoRequest(token, owner, repo, { const { sha, content, encoding } = await repoRequest(token, owner, repo, {
url: `contents/${encodeURIComponent(path)}`, url: `contents/${encodeURIComponent(path)}`,
params: { ref: branch }, 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 { return {
sha, sha,
data: !isImg ? utils.decodeBase64(content) : content, data: !isImg ? utils.decodeBase64(tempContent) : tempContent,
}; };
}, },
/** /**