PageSourceSearch

https://hotstrips.org/assets/ResetPwd-D1lc4BlK.js

js hotstrips.org collected 2026-10-02 01:06:56 UTC 4,925 bytes, 1 lines download raw bytes

1import{u as N,r as i,j as e,L as v,B as f}from"./index-D7O4L0AS.js";import{I as S,Q as I,a as B,b as T}from"./input-otp-ipNkxSRh.js";import{c as k,a as c,u as F,I as j,C as E}from"./input-DDXd1YKx.js";import{C as P,a as $,b as D,c as L,d as R}from"./card-CjKV5_U8.js";import{L as m}from"./label-CF1iDV6H.js";import{d as O,s as V}from"./api-vgGodFNJ.js";const b=k({email:c().email("请输入有效的邮箱地址").required("请输入邮箱"),password:c().min(6,"密码至少需要 6 位").required("请输入新密码"),code:c().length(6,"请输入 6 位验证码").required("请输入验证码")});function M(){const{toast:t}=N(),[o,u]=i.useState(""),[d,l]=i.useState(!1),[C,p]=i.useState(60),[h,x]=i.useState(!1),[g,w]=i.useState(!1);i.useEffect(()=>{if(!d)return;const r=window.setInterval(()=>{p(a=>a<=1?(window.clearInterval(r),l(!1),60):a-1)},1e3);return()=>window.clearInterval(r)},[d]);const s=F({initialValues:{email:"",password:"",code:""},validationSchema:b,validateOnMount:!0,onSubmit:async r=>{if(!o){t({variant:"destructive",description:"请先获取邮箱验证码"});return}w(!0);try{const a=E.SHA256(r.password).toString(),n=await O({email:r.email,password:a,code:r.code,codeId:o});if(!n.success){t({variant:"destructive",description:n.msg});return}t({description:n.msg}),l(!1),u(""),s.resetForm()}catch(a){t({variant:"destructive",description:a instanceof Error?a.message:"密码重置失败,请稍后重试"})}finally{w(!1)}}}),y=async()=>{var r;s.setFieldTouched("email",!0);try{await b.validateAt("email",s.values)}catch{t({variant:"destructive",description:"请先输入有效的邮箱地址"});return}x(!0);try{const a=await V({email:s.values.email,type:"ResetPwd"});if(!a.success){const n=(r=a.data)!=null&&r.message?`:${a.data.message}`:"";t({variant:"destructive",description:`${a.msg}${n}`});return}u(a.data.codeId),p(60),l(!0),t({description:a.msg})}catch(a){t({variant:"destructive",description:a instanceof Error?a.message:"验证码发送失败,请稍后重试"})}finally{x(!1)}};return e.jsx("main",{id:"main-content",className:"grid min-h-dvh place-items-center bg-background px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs(v,{to:"/login",className:"mb-5 inline-flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-primary",children:[e.jsx("img",{src:"/favicon.png",alt:"",className:"h-8 w-8 rounded-lg",width:"128",height:"128"}),"返回登录"]}),e.jsxs(P,{className:"border-border bg-card shadow-whisper",children:[e.jsxs($,{className:"space-y-2 pb-5",children:[e.jsx("p",{className:"kami-eyebrow",children:"账户恢复"}),e.jsx(D,{className:"text-[1.75rem] tracking-normal",children:"重置密码"}),e.jsx(L,{children:"通过邮箱验证码设置一个新密码"})]}),e.jsxs(R,{children:[e.jsxs("form",{onSubmit:s.handleSubmit,className:"grid gap-5",noValidate:!0,children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"email",children:"邮箱"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{id:"email",name:"email",type:"email",autoComplete:"email",placeholder:"[email protected]",value:s.values.email,onChange:s.handleChange,onBlur:s.handleBlur,"aria-invalid":!!(s.touched.email&&s.errors.email),"aria-describedby":"reset-email-error"}),e.jsx(f,{type:"button",variant:"outline",className:"shrink-0 px-3",disabled:d||g,onClick:y,loading:h,loadingText:"发送中",children:d?`${
1C}s`:"发送验证码"})]}),e.jsx("p",{id:"reset-email-error",className:"min-h-5 text-sm text-destructive",children:s.touched.email?s.errors.email:""})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"新密码"}),e.jsx(j,{id:"password",name:"password",type:"password",autoComplete:"new-password",value:s.values.password,onChange:s.handleChange,onBlur:s.handleBlur,"aria-invalid":!!(s.touched.password&&s.errors.password),"aria-describedby":"reset-password-error"}),e.jsx("p",{id:"reset-password-error",className:"min-h-5 text-sm text-destructive",children:s.touched.password?s.errors.password:""})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"reset-code",children:"邮箱验证码"}),e.jsx(S,{id:"reset-code",name:"code",maxLength:6,pattern:I,value:s.values.code,onChange:r=>s.setFieldValue("code",r),onBlur:()=>s.setFieldTouched("code",!0),"aria-describedby":"reset-code-error",children:e.jsx(B,{children:[0,1,2,3,4,5].map(r=>e.jsx(T,{index:r},r))})}),e.jsx("p",{id:"reset-code-error",className:"min-h-5 text-sm text-destructive",children:s.touched.code?s.errors.code:""})]}),e.jsx(f,{type:"submit",className:"w-full",disabled:!s.isValid||!o||h,loading:g,loadingText:"重置中",children:"确认重置"})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:["已经想起密码?"," ",e.jsx(v,{to:"/login",className:"font-medium text-primary hover:underline",children:"返回登录"})]})]})]})]})})}export{M as ResetPwd};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.