Prevent duplicate downloads

This commit is contained in:
Tw93
2025-11-11 15:21:20 +08:00
parent 3c8e2a753f
commit aa65c7cd19
2 changed files with 5 additions and 1 deletions

2
package.json vendored
View File

@@ -1,6 +1,6 @@
{ {
"name": "pake-cli", "name": "pake-cli",
"version": "3.4.3", "version": "3.4.4",
"description": "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。", "description": "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@@ -319,9 +319,13 @@ document.addEventListener("DOMContentLoaded", () => {
const url = anchorEle.href; const url = anchorEle.href;
const filename = anchorEle.download || getFilenameFromUrl(url); const filename = anchorEle.download || getFilenameFromUrl(url);
if (window.blobToUrlCaches.has(url)) { if (window.blobToUrlCaches.has(url)) {
e.preventDefault();
e.stopImmediatePropagation();
downloadFromBlobUrl(url, filename); downloadFromBlobUrl(url, filename);
// case: download from dataURL -> convert dataURL -> // case: download from dataURL -> convert dataURL ->
} else if (url.startsWith("data:")) { } else if (url.startsWith("data:")) {
e.preventDefault();
e.stopImmediatePropagation();
downloadFromDataUri(url, filename); downloadFromDataUri(url, filename);
} }
}, },