geekssl /

wstats

公开
main
wstats/public/assets/Forgot-DPCd-4GH.js
Forgot-DPCd-4GH.js3.5 KB
import{u as U,a as W,b as _,r as t,c as u,j as s,B as $,F as h,d as f,T as q,L as H,P as J}from"./index-DS2B3OLK.js";import{B as x}from"./index-BNK0Nj_J.js";import{T as n}from"./index-DhB1Ls4S.js";import"./IconTickCircle-Bbh_c2jr.js";function Y(){const{t:e,lang:T}=U(),z=W(),E=_(),[l,N]=t.useState(""),[c,L]=t.useState(""),[y,R]=t.useState(""),[F,j]=t.useState(!1),[b,C]=t.useState(!1),[p,D]=t.useState(null),[g,O]=t.useState(""),[m,w]=t.useState(""),[A,P]=t.useState(""),[v,S]=t.useState(""),[o,I]=t.useState(0),[r,G]=t.useState(!1),i=!!(p&&p.captcha_ready);t.useEffect(()=>{u.authPublic().then(D).catch(()=>{})},[]);const d=t.useCallback(async()=>{w("");try{const a=await u.captcha();P(a.id),S(a.image)}catch(a){P(""),S(""),n.error(a.message)}},[]);t.useEffect(()=>{i&&d()},[i,d]),t.useEffect(()=>{if(o<=0)return;const a=setInterval(()=>I(B=>B<=1?0:B-1),1e3);return()=>clearInterval(a)},[o]);const M=async()=>{if(!(o>0||b||r)){if(!l)return n.error(e("emailPh"));if(i&&!m)return n.error(e("captchaPh"));C(!0);try{const a=await u.resetCode(l,A,m,T);I(a&&a.resend||60),n.success(e("codeSent"))}catch(a){n.error(a.message)}finally{C(!1),i&&d()}}},k=async()=>{if(!l||!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 u.resetPassword(l,g,c),G(!0),n.success(e("resetOk")),setTimeout(()=>E("/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($,{})}),s.jsx("div",{className:"auth-brand",children:z.name||e("appName")}),s.jsx("div",{className:"auth-sub",children:e("forgotTitle")}),s.jsx(x,{type:"info",description:e("forgotTip"),style:{marginBottom:12},closeIcon:null}),p&&!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:l,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:w,maxLength:4,style:{flex:1},disabled:r}),v?s.jsx("img",{src:v,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:O,maxLength:6,style:{flex:1},disabled:r}),s.jsx(f,{size:"large",style:{flexShrink:0,minWidth:108},loading:b,disabled:r||o>0,onClick:M,children:o>0?`${o}s`:e("getCode")})]}),s.jsx(h,{size:"large",mode:"password",placeholder:e("newPwdPh"),value:c,onChange:L,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:F,onClick:k,disabled:r,style:{marginTop:4},children:e("resetBtn")}),s.jsx(q.Text,{style:{textAlign:"center"},children:s.jsx(H,{to:"/login",children:e("backLogin")})})]}),s.jsx("div",{style:{marginTop:20,paddingTop:14,borderTop:"1px solid #f0f1f3"},children:s.jsx(J,{})})]})})}export{Y as default};