import { ErrorBoundary } from "./error"; import Locale, { AllLangs, changeLang, getLang } from "../locales"; import { useUserStore } from "../store"; import { useEffect, useState } from "react"; import styles from "./register.module.scss"; import ChatIcon from "../icons/chatgpt.svg"; import { IconButton } from "./button"; import { showToast } from "./ui-lib"; export function Register() { const userStore = useUserStore(); const [userName, setUserName] = useState(""); const [getcode, setgetcode] = useState(""); const [codeStatus, setcodeStatus] = useState(""); const [name, setName] = useState(""); const [password, setPassword] = useState(""); const [mail, setMail] = useState(""); const [code, setCode] = useState(""); const [status, setStatus] = useState(""); const onUserName = (text: string) => { setUserName(text); }; const onName = (text: string) => { setName(text); }; const onPassword = (text: string) => { setPassword(text); }; const onMail = (text: string) => { setMail(text); }; const onCode = (text: string) => { setCode(text); }; const registerTo = () => { userStore.register(userName, password, name, mail, code); setStatus("false"); setTimeout(() => { setStatus(""); }, 4000); }; const getMailCode = () => { userStore.getMailCode(mail); 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.Register}
{Locale.User.RegisterTitle}
{/*
账号为QQ号将自动绑定QQ邮箱方便找回密码
*/}
onName(e.currentTarget.value)} value={name} >
onUserName(e.currentTarget.value)} value={userName} >
onPassword(e.currentTarget.value)} value={password} >
onMail(e.currentTarget.value)} value={mail} >
onCode(e.currentTarget.value)} value={code} > { getMailCode(); }} >
{Locale.User.Findpwd} {Locale.User.Login}
{ registerTo(); }} >
); }