/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as a,q as e,aI as s,o as l,l as t,aJ as o,p as r,w as u,I as d,aG as m,aK as n,as as i,aH as p,aL as c,z as v,u as f,Z as _,f as g,a as h,c as y,e as j,b,t as w,ac as V,aM as x,M as I,a5 as S,a6 as U,X as $,a0 as k,a2 as C,_ as q}from"./index-fe6c8641.js";/* empty css *//* empty css */import{_ as z}from"./index-7cd89372.js";import{u as B}from"./useCreate-21e18dc5.js";const E=a({__name:"index",props:{action:{type:String,default:"upload"},auto:{type:Boolean,default:!0}},emits:["success","destory"],setup(a,{emit:v}){const f=a,_=e(),g=a=>{_.value.clearFiles();const e=a[0];e.uid=n(),_.value.handleStart(e),_.value.submit()},h=(a,e)=>{e.raw,v("success",a.data)},y=(a,e)=>{v("destory")},j=(a,e)=>i.confirm(`确定要删除 ${a.name} ?`).then((()=>!0),(()=>!1)),b=p("VITE_BASE_URL"),w=e("");w.value=b+f.action;const V=e();return V.value="Bearer "+s(),(e,s)=>{const n=c;return l(),t(n,m({ref_key:"upload",ref:_,action:w.value,"auto-upload":a.auto,limit:1,"before-remove":j,"on-exceed":g,"on-remove":y,"on-success":h,headers:{authorization:V.value}},e.$attrs),o({_:2},[r(e.$slots,((a,s)=>({name:s,fn:u((()=>[d(e.$slots,s)]))})))]),1040,["action","auto-upload","headers"])}}}),F=["src"],Z={class:"flex justify-center"},A=q(a({__name:"profile",setup(a){const s=e(Object.assign({avatar:"",username:"",email:"",password:""})),{form:o,loading:r,submitForm:d,afterCreate:m}=B("user/online",null,s);v((()=>{r.value=!0,V.get("user/online").then((a=>{s.value.username=a.data.data.username,s.value.avatar=a.data.data.avatar,s.value.email=a.data.data.email,r.value=!1}))}));const n=f(),i=(a,e)=>{a.code===x.SUCCESS?(o.value.avatar=a.data.path,s.value.avatar=a.data.path):I.error(a.message)};return m.value=()=>{n.getUserInfo()},(a,e)=>{const m=z,n=E,p=S,c=U,v=$,f=k,V=C;return _((l(),t(f,{model:s.value,ref_key:"form",ref:o,"label-position":"top"},{default:u((()=>[h(n,{class:"w-28 h-28 rounded-full mx-auto",action:"upload/image","show-file-list":!1,name:"image","on-success":i},{default:u((()=>[s.value.avatar?(l(),y("img",{key:0,src:s.value.avatar,class:"h-28 rounded-full"},null,8,F)):(l(),t(m,{key:1,name:"plus"}))])),_:1}),h(c,{label:"昵称",prop:"username",class:"mt-2",rules:[{required:!0,message:"昵称必须填写"}]},{default:u((()=>[h(p,{modelValue:s.value.username,"onUpdate:modelValue":e[0]||(e[0]=a=>s.value.username=a),placeholder:"请填写昵称"},null,8,["modelValue"])])),_:1}),h(c,{label:"邮箱",prop:"email",rules:[{required:!0,message:"邮箱必须填写"},{type:"email",message:"邮箱格式不正确"}]},{default:u((()=>[h(p,{modelValue:s.value.email,"onUpdate:modelValue":e[1]||(e[1]=a=>s.value.email=a),placeholder:"请填写邮箱"},null,8,["modelValue"])])),_:1}),h(c,{label:"密码",prop:"password",rules:[{pattern:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/,message:"必须包含大小写字母和数字的组合,可以使用特殊字符,长度在6-20之间"}]},{default:u((()=>[h(p,{modelValue:s.value.password,"onUpdate:modelValue":e[2]||(e[2]=a=>s.value.password=a),type:"password","show-password":"",placeholder:"请输入密码"},null,8,["modelValue"])])),_:1},8,["rules"]),j("div",Z,[h(v,{type:"primary",onClick:e[3]||(e[3]=a=>g(d)(g(o)))},{default:u((()=>[b(w(a.$t("system.update")),1)])),_:1})])])),_:1},8,["model"])),[[V,g(r)]])}}}),[["__scopeId","data-v-6a0d7772"]]);export{A as default};