Files
epusdt/src/www/assets/sign-in-B3lOm_MY.js
T
2026-04-22 03:39:11 +08:00

1 line
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{$s as e,Qs as t,Zs as n,ac as r,ec as i,ic as a,nc as o,nu as s,ou as c,rc as l,ru as u,tc as d}from"./messages-BovT1T-w.js";import{a as f,r as p}from"./auth-store-ramu4Ja7.js";import{t as m}from"./useSearch-B5ZWp8fU.js";import{t as h}from"./useNavigate-Dg8CkCoa.js";import{i as g,t as _}from"./button-DJA4fnJ8.js";import{t as v}from"./createLucideIcon-D28ivbfF.js";import{t as y}from"./loader-circle-fg8-aSyl.js";import{n as b}from"./dist-DvAgZMq72.js";import{c as x,s as S}from"./zod-Cymc5bS-.js";import{n as C}from"./auth-animation-context-zwGs7ZAM.js";import{a as w,c as T,i as E,l as D,n as O,o as k,s as A,t as j}from"./form-DdHiBYMe.js";import{t as M}from"./input-DiRPHDd8.js";import{t as N}from"./password-input-B463LDkD.js";var P=v(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),F=c(u(),1),I=s(),L=S({username:x().min(1,e()),password:x().min(1,t())});function R({className:e,redirectTo:t,...r}){let a=h(),{setIsTyping:s,setPasswordLength:c,setShowPassword:l}=C(),u=f.useMutation(`post`,`/admin/api/v1/auth/login`),m=D({resolver:T(L),defaultValues:{username:``,password:``}});(0,F.useEffect)(()=>()=>{s(!1),c(0),l(!1)},[s,c,l]);async function v(e){let n=await u.mutateAsync({body:{username:e.username,password:e.password}});n?.data?.token&&(p(n.data.token),b.success(`欢迎回来,${n.data.username??e.username}`),a({to:t||`/dashboard`,replace:!0}))}function x(e){c(e.length)}return(0,I.jsx)(j,{...m,children:(0,I.jsxs)(`form`,{className:g(`grid gap-3`,e),onSubmit:m.handleSubmit(v),...r,children:[(0,I.jsx)(E,{control:m.control,name:`username`,render:({field:e})=>(0,I.jsxs)(w,{children:[(0,I.jsx)(k,{children:o()}),(0,I.jsx)(O,{children:(0,I.jsx)(M,{placeholder:d(),...e,onBlur:()=>{s(!1),e.onBlur()},onFocus:()=>s(!0)})}),(0,I.jsx)(A,{})]})}),(0,I.jsx)(E,{control:m.control,name:`password`,render:({field:e})=>(0,I.jsxs)(w,{children:[(0,I.jsx)(k,{children:i()}),(0,I.jsx)(O,{children:(0,I.jsx)(N,{placeholder:`********`,...e,onBlur:()=>{s(!1),e.onBlur()},onChange:t=>{x(t.target.value),e.onChange(t)},onFocus:()=>s(!0),onVisibilityChange:l})}),(0,I.jsx)(A,{})]})}),(0,I.jsxs)(_,{className:`mt-2`,disabled:u.isPending,children:[u.isPending?(0,I.jsx)(y,{className:`animate-spin`}):(0,I.jsx)(P,{}),n()]})]})})}function z(){let{redirect:e}=m({from:`/(auth)/sign-in`});return(0,I.jsxs)(`div`,{className:`w-full space-y-6`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{className:`font-medium text-primary text-sm`,children:r()}),(0,I.jsx)(`h2`,{className:`font-semibold text-3xl tracking-tight`,children:a()}),(0,I.jsx)(`p`,{className:`text-muted-foreground leading-6`,children:l()})]}),(0,I.jsx)(R,{redirectTo:e})]})}var B=z;export{B as component};