import{aj as B,ao as U,ak as C,z as p,D as b,c as v,f as s,N as A,ab as i,t,g as V,p as f,an as u,ah as D,o as w,h as y,az as I,aA as T,ai as j}from"./index-DpP8vbvu.js";import{E as z}from"./el-dialog-wajnArIT.js";/* empty css                       *//* empty css                  *//* empty css                 */import{d as L}from"./account-DtcKrNwO.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as O}from"./vnode-DPqF99Zc.js";import{E as q}from"./index-BWeK8p2T.js";import{E as G}from"./index-CcAtbSPY.js";import"./event-BB_Ol6Sd.js";import"./index-D7KcZu8a.js";import"./index-BMdPKuCq.js";const H={class:"box"},J={class:"container"},K={class:"title"},Q={class:"item"},R={key:0,class:"edit-name-input"},W={key:1,class:"user-name"},X={class:"item"},Y={class:"item"},Z={class:"del-email"},x={class:"title"},ee={style:{color:"var(--regular-text-color)"}},se={class:"update-pwd"},te=Object.assign({name:"setting"},{__name:"index",setup(ae){const{t:o}=B(),$=U(),r=C(),c=p(!1),g=p(!1),d=p(null);function P(){d.value=r.user.name,g.value=!0}function S(){if(!d.value){u({message:o("emptyUserNameMsg"),type:"error",plain:!0});return}g.value=!1;let e=d.value;e!==r.user.name&&(r.user.name=d.value,L(r.user.accountId,e).then(()=>{u({message:o("saveSuccessMsg"),type:"success",plain:!0}),$.changeUserAccountName=e}).catch(()=>{r.user.name=e}))}const m=p(!1),a=b({password:"",newPwd:""}),k=()=>{G.confirm(o("delAccountConfirm"),{confirmButtonText:o("confirm"),cancelButtonText:o("cancel"),type:"warning"}).then(()=>{T().then(()=>{localStorage.removeItem("token"),j.replace("/login"),u({message:o("delSuccessMsg"),type:"success",plain:!0})})})};function N(){if(!a.password){u({message:o("emptyPwdMsg"),type:"error",plain:!0});return}if(a.password.length<6){u({message:o("pwdLengthMsg"),type:"error",plain:!0});return}if(a.password!==a.newPwd){u({message:o("confirmPwdFailMsg"),type:"error",plain:!0});return}c.value=!0,I(a.password).then(()=>{u({message:o("saveSuccessMsg"),type:"success",plain:!0}),m.value=!1,c.value=!1,a.password="",a.newPwd=""}).catch(()=>{c.value=!1})}return(e,l)=>{const _=O,h=q,E=z,M=D("perm");return w(),v("div",H,[s("div",J,[s("div",K,t(e.$t("profile")),1),s("div",Q,[s("div",null,t(e.$t("username")),1),s("div",null,[g.value?(w(),v("span",R,[i(_,{modelValue:d.value,"onUpdate:modelValue":l[0]||(l[0]=n=>d.value=n)},null,8,["modelValue"]),s("span",{class:"edit-name",onClick:S},t(e.$t("save")),1)])):(w(),v("span",W,[s("span",null,t(V(r).user.name),1),s("span",{class:"edit-name",onClick:P},t(e.$t("change")),1)]))])]),s("div",X,[s("div",null,t(e.$t("emailAccount")),1),s("div",null,t(V(r).user.email),1)]),s("div",Y,[s("div",null,t(e.$t("password")),1),s("div",null,[i(h,{type:"primary",onClick:l[1]||(l[1]=n=>m.value=!0)},{default:f(()=>[y(t(e.$t("changePwdBtn")),1)]),_:1})])])]),A((w(),v("div",Z,[s("div",x,t(e.$t("deleteUser")),1),s("div",ee,t(e.$t("delAccountMsg")),1),s("div",null,[i(h,{type:"primary",onClick:k},{default:f(()=>[y(t(e.$t("deleteUserBtn")),1)]),_:1})])])),[[M,"my:delete"]]),i(E,{modelValue:m.value,"onUpdate:modelValue":l[4]||(l[4]=n=>m.value=n),title:e.$t("changePassword"),width:"340"},{default:f(()=>[s("div",se,[i(_,{type:"password",placeholder:e.$t("newPassword"),modelValue:a.password,"onUpdate:modelValue":l[2]||(l[2]=n=>a.password=n),autocomplete:"off"},null,8,["placeholder","modelValue"]),i(_,{type:"password",placeholder:e.$t("confirmPassword"),modelValue:a.newPwd,"onUpdate:modelValue":l[3]||(l[3]=n=>a.newPwd=n),autocomplete:"off"},null,8,["placeholder","modelValue"]),i(h,{type:"primary",loading:c.value,onClick:N},{default:f(()=>[y(t(e.$t("save")),1)]),_:1},8,["loading"])])]),_:1},8,["modelValue","title"])])}}}),ge=F(te,[["__scopeId","data-v-1b447be1"]]);export{ge as default};
