mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 07:51:14 +00:00
feat: add download token handling and update verification flow in CloudflarePopup
This commit is contained in:
@@ -878,6 +878,8 @@ function CloudflarePopup({ file }: { file: RFile }) {
|
|||||||
|
|
||||||
const [isLoading, setLoading] = useState(true);
|
const [isLoading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
const [downloadToken, setDownloadToken] = useState<string | null>(null);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -887,31 +889,50 @@ function CloudflarePopup({ file }: { file: RFile }) {
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
"absolute top-0 bottom-0 left-0 right-0 flex items-center justify-center"
|
"absolute top-0 bottom-8 left-0 right-0 flex items-center justify-center"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className={"loading loading-spinner loading-lg"}></span>
|
<span className={"loading loading-spinner loading-lg"}></span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<h3 className={"font-bold m-2"}>{t("Verifying your request")}</h3>
|
<h3 className={"font-bold m-2"}>
|
||||||
<div className={"h-20 w-full"}>
|
{downloadToken ? t("Verification successful") : t("Verifying your request")}
|
||||||
<Turnstile
|
</h3>
|
||||||
siteKey={app.cloudflareTurnstileSiteKey!}
|
{!downloadToken && (
|
||||||
onWidgetLoad={() => {
|
<>
|
||||||
setLoading(false);
|
<div className={"h-20 w-full"}>
|
||||||
}}
|
<Turnstile
|
||||||
onSuccess={(token) => {
|
siteKey={app.cloudflareTurnstileSiteKey!}
|
||||||
closePopup();
|
onWidgetLoad={() => {
|
||||||
const link = network.getFileDownloadLink(file.id, token);
|
setLoading(false);
|
||||||
window.open(link, "_blank");
|
}}
|
||||||
}}
|
onSuccess={(token) => {
|
||||||
></Turnstile>
|
setDownloadToken(token);
|
||||||
</div>
|
}}
|
||||||
<p className={"text-xs text-base-content/80 m-2"}>
|
></Turnstile>
|
||||||
{t(
|
</div>
|
||||||
"Please check your network if the verification takes too long or the captcha does not appear.",
|
<p className={"text-xs text-base-content/80 m-2"}>
|
||||||
)}
|
{t(
|
||||||
</p>
|
"Please check your network if the verification takes too long or the captcha does not appear.",
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{downloadToken && (
|
||||||
|
<div className="p-2">
|
||||||
|
<a
|
||||||
|
href={network.getFileDownloadLink(file.id, downloadToken)}
|
||||||
|
target="_blank"
|
||||||
|
className="btn btn-primary btn-sm w-full"
|
||||||
|
onClick={() => {
|
||||||
|
closePopup();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MdOutlineDownload size={20} />
|
||||||
|
{t("Download")}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user