diff --git a/apps/frontend/components/human-verification.tsx b/apps/frontend/components/human-verification.tsx new file mode 100644 index 0000000..56c88ee --- /dev/null +++ b/apps/frontend/components/human-verification.tsx @@ -0,0 +1,53 @@ +"use client" + +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { ReactNode, useEffect, useState } from "react" + +interface HumanVerificationProps { + open?: boolean; + onOpenChange?: (open: boolean) => void; + onSuccess?: () => void; + onFail?: (reason?: string) => void; + children: ReactNode; +} + +export function HumanVerification({ open, onOpenChange, onSuccess, onFail, children }: HumanVerificationProps) { + const [i_open, i_setOpen] = useState(false); + const setOpen = (o: boolean) => { + i_setOpen(o); + onOpenChange?.(o); + }; + + useEffect(() => { + if (i_open) { + setOpen(false); + onSuccess?.(); + } + }, [i_open]); + + return ( + + + {children} + + + + 人机验证 + + 请拖动滑块以使得图片水平 + + +
+ +
+
+
+ ) +} \ No newline at end of file