Skip to content

Commit

Permalink
修复图片下载失败的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jooooock committed Dec 3, 2024
1 parent bff37d0 commit b70086c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export async function packHTMLAssets(html: string, title: string, zip?: JSZip) {

// 下载所有的图片
const imgDownloadFn = async (img: HTMLImageElement, proxy: string) => {
const url = img.src || img.dataset.src!
const url = img.getAttribute('src') || img.getAttribute('data-src')
if (!url) {
return 0
}
Expand All @@ -558,7 +558,7 @@ export async function packHTMLAssets(html: string, title: string, zip?: JSZip) {

return imgData.size
}
const imgs = Array.from($jsArticleContent.querySelectorAll<HTMLImageElement>('img')).filter(img => img.getAttribute('src')?.trim())
const imgs = $jsArticleContent.querySelectorAll<HTMLImageElement>('img')
if (imgs.length > 0) {
await pool.downloads<HTMLImageElement>([...imgs], imgDownloadFn)
}
Expand Down

0 comments on commit b70086c

Please sign in to comment.