Add loading spinner to Cloudflare popup during Turnstile verification

This commit is contained in:
2025-05-18 15:54:49 +08:00
parent 3f4c616b13
commit 746d44a66f

View File

@@ -274,8 +274,17 @@ function FileTile({file}: { file: RFile }) {
function CloudflarePopup({file}: { file: RFile }) { function CloudflarePopup({file}: { file: RFile }) {
const closePopup = useClosePopup() const closePopup = useClosePopup()
return <div className={"menu bg-base-100 rounded-box z-1 w-80 p-2 shadow-sm h-20"}> const [isLoading, setLoading] = useState(false)
<Turnstile siteKey={app.cloudflareTurnstileSiteKey!} onSuccess={(token) => {
return <div className={"menu bg-base-100 rounded-box z-1 w-80 p-2 shadow-sm h-20 relative"}>
{
isLoading ? <div className={"absolute top-0 bottom-0 left-0 right-0 flex items-center justify-center"}>
<span className={"loading loading-spinner loading-lg"}></span>
</div> : null
}
<Turnstile siteKey={app.cloudflareTurnstileSiteKey!} onLoad={() => {
setLoading(false)
}} onSuccess={(token) => {
closePopup(); closePopup();
const link = network.getFileDownloadLink(file.id, token); const link = network.getFileDownloadLink(file.id, token);
window.open(link, "_blank"); window.open(link, "_blank");