Files
aiot-platform-ui/apps/web-antd/dist/js/forget-password-DB8KWPW4.js
lzh 19d36d1ffb
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 8s
chore: build and deploy web-antd
2026-03-09 13:05:46 +08:00

2 lines
4.7 KiB
JavaScript

var g=(l,c,u)=>new Promise((h,s)=>{var m=o=>{try{p(u.next(o))}catch(f){s(f)}},i=o=>{try{p(u.throw(o))}catch(f){s(f)}},p=o=>o.done?h(o.value):Promise.resolve(o.value).then(m,i);p((u=u.apply(l,c)).next())});import{a3 as _,V as x,$ as t,X as F,a5 as $,a6 as k,a7 as w,a8 as E,a9 as I,aa as L,ab as R,ad as M}from"./bootstrap-CRjSNGHY.js";import{A as D}from"./auth-title-3QjdlwxU.js";import{m as A,b7 as q,aa as N,ad as j,b2 as B,j as T,ae as z,bJ as P,bc as V,ai as v,bp as S,u as d,aR as G,b9 as y,v as H,ab as J}from"../jse/index-index-CMeVxoEG.js";const O=A({name:"ForgetPassword",__name:"forget-password",props:{formSchema:{},loading:{type:Boolean,default:!1},loginPath:{default:"/auth/login"},title:{default:""},subTitle:{default:""},submitButtonText:{default:""}},emits:["submit"],setup(l,{expose:c,emit:u}){const h=l,s=u,[m,i]=_(q({commonConfig:{hideLabel:!0,hideRequiredMark:!0},schema:N(()=>h.formSchema),showDefaultActions:!1})),p=x();function o(){return g(this,null,function*(){const{valid:e}=yield i.validate(),a=yield i.getValues();e&&s("submit",a)})}function f(){p.push(h.loginPath)}return c({getFormApi:()=>i}),(e,a)=>(B(),j("div",null,[T(D,null,{desc:P(()=>[V(e.$slots,"subTitle",{},()=>[v(S(l.subTitle||d(t)("authentication.forgetPasswordSubtitle")),1)])]),default:P(()=>[V(e.$slots,"title",{},()=>[v(S(l.title||d(t)("authentication.forgetPassword"))+" 🤦🏻‍♂️ ",1)])]),_:3}),T(d(m)),z("div",null,[T(d(F),{class:G([{"cursor-wait":l.loading},"mt-2 w-full"]),"aria-label":"submit",onClick:o},{default:P(()=>[V(e.$slots,"submitButtonText",{},()=>[v(S(l.submitButtonText||d(t)("authentication.resetPassword")),1)])]),_:3},8,["class"]),T(d(F),{class:"mt-4 w-full",variant:"outline",onClick:a[0]||(a[0]=r=>f())},{default:P(()=>[v(S(d(t)("common.back")),1)]),_:1})])]))}}),C=6,U=A({name:"ForgetPassword",__name:"forget-password",setup(l){const c=$(),u=x(),h=k(),s=y(!1),m=y(),i=y([]);function p(){return g(this,null,function*(){var e,a;try{const r=L(window.location.hostname);i.value=yield R();let n=null;const b=yield r;b!=null&&b.id&&(n=b.id),!n&&c.tenantId&&(n=c.tenantId),!n&&((a=(e=i.value)==null?void 0:e[0])!=null&&a.id)&&(n=i.value[0].id),c.setTenantId(n),m.value.getFormApi().setFieldValue("tenantId",n==null?void 0:n.toString())}catch(r){console.error("获取租户列表失败:",r)}})}H(()=>{p()});const o=N(()=>[{component:"VbenSelect",componentProps:{options:i.value.map(e=>({label:e.name,value:e.id.toString()})),placeholder:t("authentication.tenantTip")},fieldName:"tenantId",label:t("authentication.tenant"),rules:w().min(1,{message:t("authentication.tenantTip")}),dependencies:{triggerFields:["tenantId"],if:h,trigger(e){e.tenantId&&c.setTenantId(Number(e.tenantId))}}},{component:"VbenInput",componentProps:{placeholder:t("authentication.mobile")},fieldName:"mobile",label:t("authentication.mobile"),rules:w().min(1,{message:t("authentication.mobileTip")}).refine(e=>/^\d{11}$/.test(e),{message:t("authentication.mobileErrortip")})},{component:"VbenPinInput",componentProps:{codeLength:C,createText:e=>e>0?t("authentication.sendText",[e]):t("authentication.sendCode"),placeholder:t("authentication.code"),handleSendCode:()=>g(null,null,function*(){var e;s.value=!0;try{const a=(e=m.value)==null?void 0:e.getFormApi();if(!a)throw new Error("表单未准备好");if(yield a.validateField("mobile"),!(yield a.isFieldValid("mobile")))throw new Error("请输入有效的手机号码");const{mobile:n}=yield a.getValues();yield E({mobile:n,scene:23}),I.success("验证码发送成功")}finally{s.value=!1}})},fieldName:"code",label:t("authentication.code"),rules:w().length(C,{message:t("authentication.codeTip",[C])})},{component:"VbenInputPassword",componentProps:{passwordStrength:!0,placeholder:t("authentication.password")},fieldName:"password",label:t("authentication.password"),renderComponentContent(){return{strengthText:()=>t("authentication.passwordStrength")}},rules:w().min(1,{message:t("authentication.passwordTip")})},{component:"VbenInputPassword",componentProps:{placeholder:t("authentication.confirmPassword")},dependencies:{rules(e){const{password:a}=e;return w({required_error:t("authentication.passwordTip")}).min(1,{message:t("authentication.passwordTip")}).refine(r=>r===a,{message:t("authentication.confirmPasswordTip")})},triggerFields:["password"]},fieldName:"confirmPassword",label:t("authentication.confirmPassword")}]);function f(e){return g(this,null,function*(){s.value=!0;try{const{mobile:a,code:r,password:n}=e;yield M({mobile:a,code:r,password:n}),I.success(t("authentication.resetPasswordSuccess")),yield u.push("/")}catch(a){console.error("重置密码失败:",a)}finally{s.value=!1}})}return(e,a)=>(B(),J(d(O),{ref_key:"forgetPasswordRef",ref:m,"form-schema":o.value,loading:s.value,onSubmit:f},null,8,["form-schema","loading"]))}});export{U as default};