import { ErrorBoundary } from "./error"; import Locale from "../locales"; import ChatIcon from "../icons/chatgpt.svg" import styles from "./findpwd.module.scss"; import { IconButton } from "./button"; import { useUserStore } from "../store"; import { useEffect, useState } from "react"; export function FindPwd(){ const userStore=useUserStore() const [email, setEmail] = useState(""); const [status, setStatus] = useState(""); const [code, setCode] = useState(""); const [codeStatus, setcodeStatus] = useState(""); const [getcode, setgetcode] = useState(""); const onEmail = (text: string) => { setEmail(text) }; const onCode = (text: string) => { setCode(text) }; async function findpwd(){ setStatus("false") await useUserStore.getState().findPwd(email,code) setTimeout(()=>{ setStatus("") },4000) } const getMailCode=()=>{ userStore.getRestPwdCode(email) getCode() } var countdown=60; const getCode=()=>{ if (countdown == 0) { setcodeStatus("") setgetcode("发送验证码") countdown = 60; return; } else { setcodeStatus("true") setgetcode("(" + countdown + ")") countdown--; } setTimeout(function() { getCode() } ,1000) } useEffect(()=>{ setcodeStatus("") setgetcode("发送验证码") },[]) return (
{Locale.User.Findpwd}
{Locale.User.FindpwdTitle}
onEmail(e.currentTarget.value)} value={email} >
onCode(e.currentTarget.value)} value={code} > { getMailCode() }} >
{Locale.User.Login} {Locale.User.Register}
{ findpwd() }} >
); }