geekssl /

wstats

公开
main
wstats/public/assets/Register-lXlAWwXJ.js
Register-lXlAWwXJ.js3.5 KB
import{u as $,a as q,b as H,r as a,c as m,j as e,B as J,F as h,d as y,T as K,L as M,P as O,s as Q}from"./index-DS2B3OLK.js";import{B as z}from"./index-BNK0Nj_J.js";import{T as r}from"./index-DhB1Ls4S.js";import"./IconTickCircle-Bbh_c2jr.js";function ee(){const{t:s,lang:N}=$(),R=q(),E=H(),[j,L]=a.useState(""),[c,_]=a.useState(""),[u,F]=a.useState(""),[A,v]=a.useState(!1),[C,b]=a.useState(!1),[i,D]=a.useState(null),[x,G]=a.useState(""),[f,S]=a.useState(""),[U,P]=a.useState(""),[k,w]=a.useState(""),[o,I]=a.useState(0),p=!!(i&&!i.registration_enabled),l=!!(i&&i.registration_enabled&&i.email_verify_enabled),g=!!(i&&i.captcha_ready);a.useEffect(()=>{m.authPublic().then(D).catch(()=>{})},[]);const d=a.useCallback(async()=>{S("");try{const t=await m.captcha();P(t.id),w(t.image)}catch(t){P(""),w(""),r.error(t.message)}},[]);a.useEffect(()=>{l&&g&&d()},[l,g,d]),a.useEffect(()=>{if(o<=0)return;const t=setInterval(()=>I(T=>T<=1?0:T-1),1e3);return()=>clearInterval(t)},[o]);const W=async()=>{if(!(o>0||C)){if(!c)return r.error(s("emailPh"));if(!f)return r.error(s("captchaPh"));b(!0);try{const t=await m.emailCode(c,U,f,N);I(t&&t.resend||60),r.success(s("codeSent"))}catch(t){r.error(t.message)}finally{b(!1),d()}}},B=async()=>{if(p)return r.error(s("setRegClosed"));if(!c||!u)return r.error(s("email")+" / "+s("password"));if(u.length<8)return r.error(s("pwdPh"));if(l&&!x)return r.error(s("emailCodePh"));v(!0);try{const t=await m.register(c,u,j,l?x:void 0);Q(t.token),E("/overview",{replace:!0})}catch(t){r.error(t.message)}finally{v(!1)}},n=p||l&&!g;return e.jsx("div",{className:"auth-page",children:e.jsxs("div",{className:"auth-card",children:[e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:8},children:e.jsx(J,{})}),e.jsx("div",{className:"auth-brand",children:R.name||s("appName")}),e.jsx("div",{className:"auth-sub",children:s("registerTitle")}),p&&e.jsx(z,{type:"warning",description:s("setRegClosed"),style:{marginBottom:12},closeIcon:null}),!p&&l&&!g&&e.jsx(z,{type:"danger",description:s("captchaNoGd"),style:{marginBottom:12},closeIcon:null}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,opacity:n?.5:1},children:[e.jsx(h,{size:"large",placeholder:s("nickname"),value:j,onChange:L,disabled:n}),e.jsx(h,{size:"large",placeholder:s("emailPh"),value:c,onChange:_,disabled:n}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(h,{size:"large",placeholder:s("captchaPh"),value:f,onChange:S,maxLength:4,style:{flex:1},disabled:n}),k?e.jsx("img",{src:k,alt:s("captchaPh"),title:s("captchaRefresh"),onClick:d,style:{width:132,height:44,borderRadius:6,cursor:"pointer",border:"1px solid var(--semi-color-border)",flexShrink:0,objectFit:"cover"}}):e.jsx(y,{size:"large",onClick:d,style:{flexShrink:0},children:s("captchaRefresh")})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(h,{size:"large",placeholder:s("emailCodePh"),value:x,onChange:G,maxLength:6,style:{flex:1},disabled:n}),e.jsx(y,{size:"large",style:{flexShrink:0,minWidth:108},loading:C,disabled:n||o>0,onClick:W,children:o>0?`${o}s`:s("getCode")})]})]}),e.jsx(h,{size:"large",mode:"password",placeholder:s("pwdPh"),value:u,onChange:F,onEnterPress:B,disabled:n}),e.jsx(y,{size:"large",theme:"solid",loading:A,onClick:B,disabled:n,style:{marginTop:4},children:s("registerBtn")}),e.jsx(K.Text,{style:{textAlign:"center"},children:e.jsx(M,{to:"/login",children:s("haveAccount")})})]}),e.jsx("div",{style:{marginTop:20,paddingTop:14,borderTop:"1px solid #f0f1f3"},children:e.jsx(O,{})})]})})}export{ee as default};