fix(share): remove infiplot file download event before enter gallery page

Signed-off-by: baizhi958216 <1475289190@qq.com>
This commit is contained in:
baizhi958216
2026-06-08 19:24:40 +08:00
parent fc62c9edf5
commit 1d12417cb0
+22 -22
View File
@@ -1027,28 +1027,28 @@ function PlayInner() {
// way; this happens in the background. Server returns 503 if // way; this happens in the background. Server returns 503 if
// GALLERY_SECRET isn't configured, in which case we silently skip — the // GALLERY_SECRET isn't configured, in which case we silently skip — the
// local view still works, just no share file. // local view still works, just no share file.
void (async () => { // void (async () => {
try { // try {
const r = await fetch("/api/gallery-pack", { // const r = await fetch("/api/gallery-pack", {
method: "POST", // method: "POST",
headers: { "Content-Type": "application/json" }, // headers: { "Content-Type": "application/json" },
body: JSON.stringify({ docStr }), // body: JSON.stringify({ docStr }),
}); // });
if (!r.ok) return; // if (!r.ok) return;
const blob = await r.blob(); // const blob = await r.blob();
const url = URL.createObjectURL(blob); // const url = URL.createObjectURL(blob);
const a = document.createElement("a"); // const a = document.createElement("a");
a.href = url; // a.href = url;
a.download = `infiplot-${id}.infiplot`; // a.download = `infiplot-${id}.infiplot`;
a.rel = "noopener"; // a.rel = "noopener";
document.body.appendChild(a); // document.body.appendChild(a);
a.click(); // a.click();
a.remove(); // a.remove();
setTimeout(() => URL.revokeObjectURL(url), 2000); // setTimeout(() => URL.revokeObjectURL(url), 2000);
} catch { // } catch {
// network / decrypt error — local view above already worked // // network / decrypt error — local view above already worked
} // }
})(); // })();
}, [trimGalleryExports]); }, [trimGalleryExports]);
const handleExportStory = useCallback(() => { const handleExportStory = useCallback(() => {