import{d as v,u as V,c as b,e as o,a,w as l,r as d,o as h,i as x,k as m,j as k,g as C}from"./index-CcdGGfCj.js";import{h as S,c as q,a as B,_ as E}from"./http-CGjljVXL.js";import{_ as N}from"./PageHeader.vue_vue_type_script_setup_true_lang-ClDoYPHj.js";import{u as R}from"./auth-EXu5ynQ_.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";const U={class:"page-stack security-page"},A={class:"panel security-panel"},$={class:"security-intro"},j={class:"security-icon"},z={class:"form-actions"},I=v({__name:"SecurityView",setup(L){const w=C(),f=R(),c=V(),p=m(),u=m(!1),s=k({currentPassword:"",newPassword:"",confirmPassword:""}),_={currentPassword:[{required:!0,message:"请输入当前密码",trigger:"blur"}],newPassword:[{required:!0,message:"请输入新密码",trigger:"blur"},{min:8,max:20,message:"密码长度必须为 8～20 位",trigger:"blur"}],confirmPassword:[{required:!0,message:"请再次输入新密码",trigger:"blur"},{validator:(n,e,r)=>e===s.newPassword?r():r(new Error("两次输入的新密码不一致")),trigger:"blur"}]};async function g(){var n;if(await((n=p.value)==null?void 0:n.validate().catch(()=>!1))){u.value=!0;try{await S.put("/auth/password",{current_password:s.currentPassword,new_password:s.newPassword,confirm_password:s.confirmPassword}),q(),f.profile=null,c.success("密码已修改，请使用新密码重新登录"),await w.replace("/login")}catch(e){const r=B(e);c.error(r.message,r.copyText)}finally{u.value=!1}}}return(n,e)=>{const r=d("el-input"),i=d("el-form-item"),P=d("el-button"),y=d("el-form");return h(),b("div",U,[o(N,{title:"账号安全"}),a("section",A,[a("div",$,[a("span",j,[o(E,{name:"Lock",size:22})]),e[3]||(e[3]=a("div",null,[a("h3",null,"修改管理员密码"),a("p",null,"需验证当前密码。修改成功后将退出当前账号，请使用新密码重新登录。")],-1))]),o(y,{ref_key:"formRef",ref:p,model:s,rules:_,"label-position":"top",class:"password-form"},{default:l(()=>[o(i,{label:"当前密码",prop:"currentPassword"},{default:l(()=>[o(r,{modelValue:s.currentPassword,"onUpdate:modelValue":e[0]||(e[0]=t=>s.currentPassword=t),type:"password",autocomplete:"current-password","show-password":"",placeholder:"请输入当前密码"},null,8,["modelValue"])]),_:1}),o(i,{label:"新密码",prop:"newPassword"},{default:l(()=>[o(r,{modelValue:s.newPassword,"onUpdate:modelValue":e[1]||(e[1]=t=>s.newPassword=t),type:"password",autocomplete:"new-password","show-password":"",placeholder:"请输入 8～20 位新密码"},null,8,["modelValue"])]),_:1}),o(i,{label:"确认新密码",prop:"confirmPassword"},{default:l(()=>[o(r,{modelValue:s.confirmPassword,"onUpdate:modelValue":e[2]||(e[2]=t=>s.confirmPassword=t),type:"password",autocomplete:"new-password","show-password":"",placeholder:"请再次输入新密码"},null,8,["modelValue"])]),_:1}),a("div",z,[o(P,{type:"primary",loading:u.value,onClick:g},{default:l(()=>[...e[4]||(e[4]=[x("确认修改",-1)])]),_:1},8,["loading"])])]),_:1},8,["model"])])])}}}),K=T(I,[["__scopeId","data-v-003dbbf8"]]);export{K as default};
