码桶

发现社区成员的开源项目

geekssl /

wstats

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