码桶
发现社区成员的开源项目
Login-TTGtdzrY.js1.6 KB
import{u as y,a as v,r as a,b as l,j as e,F as c,T as d,L as u,B as T,P as b,s as w,i as N}from"./index-GWuvg2UH.js";import{T as p}from"./index-BW_2QB9V.js";import"./IconTickCircle-BYgwCdAe.js";function E(){const{t:s}=y(),g=v(),[i,h]=a.useState(""),[n,x]=a.useState(""),[m,r]=a.useState(!1),[f,j]=a.useState(!0);a.useEffect(()=>{l.authPublic().then(t=>j(!!(t&&t.registration_enabled))).catch(()=>{})},[]);const o=async()=>{if(!i||!n)return p.error(s("email")+" / "+s("password"));r(!0);try{const t=await l.login(i,n);w(t.token),g(N()?"/m":"/overview",{replace:!0})}catch(t){p.error(t.message)}finally{r(!1)}};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("div",{className:"logo-badge",children:"W"})}),e.jsx("div",{className:"auth-brand",children:s("appName")}),e.jsx("div",{className:"auth-sub",children:s("loginTitle")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx(c,{size:"large",placeholder:s("emailPh"),value:i,onChange:h}),e.jsx(c,{size:"large",mode:"password",placeholder:s("pwdPh"),value:n,onChange:x,onEnterPress:o}),e.jsx(d.Text,{style:{textAlign:"right",marginTop:-8,fontSize:13},children:e.jsx(u,{to:"/forgot",children:s("forgotLink")})}),e.jsx(T,{size:"large",theme:"solid",loading:m,onClick:o,style:{marginTop:4},children:s("loginBtn")}),f&&e.jsx(d.Text,{style:{textAlign:"center"},children:e.jsx(u,{to:"/register",children:s("noAccount")})})]}),e.jsx("div",{style:{marginTop:20,paddingTop:14,borderTop:"1px solid #f0f1f3"},children:e.jsx(b,{})})]})})}export{E as default};