From 0a2a0df554f706e1b0fd25885d2368be75081385 Mon Sep 17 00:00:00 2001 From: WittF Date: Sat, 21 Jun 2025 21:23:35 +0800 Subject: [PATCH] fix(EntityRow&FileRow): close loading window after download starts --- src/component/Admin/Entity/EntityRow.tsx | 7 ++++++- src/component/Admin/File/FileRow.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/component/Admin/Entity/EntityRow.tsx b/src/component/Admin/Entity/EntityRow.tsx index 94867c1..ad9594a 100644 --- a/src/component/Admin/Entity/EntityRow.tsx +++ b/src/component/Admin/Entity/EntityRow.tsx @@ -51,7 +51,12 @@ const EntityRow = ({ setOpenLoading(true); dispatch(getEntityUrl(entity?.id ?? 0)) .then((url) => { - entityLink ? (entityLink.location.href = url) : window.open(url, "_blank"); + if (entityLink) { + entityLink.close(); + window.open(url, "_blank"); + } else { + window.open(url, "_blank"); + } }) .finally(() => { setOpenLoading(false); diff --git a/src/component/Admin/File/FileRow.tsx b/src/component/Admin/File/FileRow.tsx index 3c1f56c..90d6116 100644 --- a/src/component/Admin/File/FileRow.tsx +++ b/src/component/Admin/File/FileRow.tsx @@ -72,7 +72,12 @@ const FileRow = ({ fileLink?.document.write("Loading file URL..."); dispatch(getFileUrl(file?.id ?? 0)) .then((url) => { - fileLink ? (fileLink.location.href = url) : window.open(url, "_blank"); + if (fileLink) { + fileLink.close(); + window.open(url, "_blank"); + } else { + window.open(url, "_blank"); + } }) .finally(() => { setOpenLoading(false);