fix(gallery): address review findings in zip download module

- Handle downloadImagesAsZip return value and surface errors to user
- Fix inferImageExtension garbage output for data URIs without semicolons
- Scale blob URL revocation delay for large zip files (>5MB → 60s)
- Cap uniqueZipPath dedup loop at 10k iterations with timestamp fallback
- Support relative URLs in inferImageExtension via base URL
- Handle svg+xml MIME subtype correctly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-07 22:32:23 +08:00
parent 7925e9c459
commit 867c52c24f
2 changed files with 22 additions and 9 deletions
+8 -1
View File
@@ -858,7 +858,14 @@ function GalleryInner() {
name: `infiplot-branch-${String(branchN).padStart(3, "0")}.${inferImageExtension(alt.imageUrl)}`,
});
}
await downloadImagesAsZip(files, `infiplot-gallery-${doc.id}.zip`);
const result = await downloadImagesAsZip(files, `infiplot-gallery-${doc.id}.zip`);
if (result.downloaded === 0) {
alert("所有图片抓取失败,请检查网络后重试");
} else if (result.failed.length > 0) {
alert(`已打包 ${result.downloaded} 张,${result.failed.length} 张抓取失败`);
}
} catch {
alert("打包下载失败,请重试");
} finally {
setDownloadingScenes(false);
}