From 48790ef5e030315800866ca7e97ca4a81db1c8b3 Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 27 Nov 2025 22:21:53 +0800 Subject: [PATCH] feat: add download token handling and update verification flow in CloudflarePopup --- frontend/src/pages/resource_details_page.tsx | 61 +++++++++++++------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/frontend/src/pages/resource_details_page.tsx b/frontend/src/pages/resource_details_page.tsx index 002315f..45f48c3 100644 --- a/frontend/src/pages/resource_details_page.tsx +++ b/frontend/src/pages/resource_details_page.tsx @@ -878,6 +878,8 @@ function CloudflarePopup({ file }: { file: RFile }) { const [isLoading, setLoading] = useState(true); + const [downloadToken, setDownloadToken] = useState(null); + const { t } = useTranslation(); return ( @@ -887,31 +889,50 @@ function CloudflarePopup({ file }: { file: RFile }) { {isLoading ? (
) : null} -

{t("Verifying your request")}

-
- { - setLoading(false); - }} - onSuccess={(token) => { - closePopup(); - const link = network.getFileDownloadLink(file.id, token); - window.open(link, "_blank"); - }} - > -
-

- {t( - "Please check your network if the verification takes too long or the captcha does not appear.", - )} -

+

+ {downloadToken ? t("Verification successful") : t("Verifying your request")} +

+ {!downloadToken && ( + <> +
+ { + setLoading(false); + }} + onSuccess={(token) => { + setDownloadToken(token); + }} + > +
+

+ {t( + "Please check your network if the verification takes too long or the captcha does not appear.", + )} +

+ + )} + {downloadToken && ( +
+ { + closePopup(); + }} + > + + {t("Download")} + +
+ )} ); }