import{_ as R,u as P,a as p,k as u,b as g,c as w,d as r,s as T,l as a,m as l,f as o,p as y,v as U,g as z,q as N,x as B,y as M,E as V,z as A,A as I}from"./index-B51TLSWN.js";const K={class:"auth-shell register-shell"},S={class:"auth-grid"},$={class:"form-panel"},F={class:"form-card register-card compact-card"},G={class:"captcha-row"},H=["src"],L={class:"helper-row"},O={key:0},j={key:1},D={__name:"index",setup(J){const k=P(),v=p(null),f=p(!1),i=p(!1),h=p(""),s=p({username:"",password:"",confirmPassword:"",code:"",uuid:""}),x={username:[{required:!0,trigger:"blur",message:"请输入账号"},{min:2,max:20,trigger:"blur",message:"账号长度需在 2 到 20 个字符之间"}],password:[{required:!0,trigger:"blur",message:"请输入密码"},{min:5,max:20,trigger:"blur",message:"密码长度需在 5 到 20 个字符之间"},{pattern:/^[^<>"'|\\]+$/,trigger:"blur",message:"密码不能包含非法字符"}],confirmPassword:[{required:!0,trigger:"blur",message:"请再次输入密码"},{validator:(t,e,n)=>{if(s.value.password!==e){n(new Error("两次输入的密码不一致"));return}n()},trigger:"blur"}],code:[{required:!0,trigger:"change",message:"请输入验证码"}]};function _(){if(!v.value){V.error("注册表单未初始化");return}v.value.validate(t=>{t&&(f.value=!0,A({username:s.value.username,password:s.value.password,code:s.value.code,uuid:s.value.uuid}).then(()=>{I.alert(`<span>账号 <strong>${s.value.username}</strong> 注册成功，现在可以直接登录。</span>`,"注册成功",{dangerouslyUseHTMLString:!0,type:"success"}).then(()=>{k.push({path:"/login",query:{username:s.value.username,registered:"1"}})})}).catch(e=>{V.error((e==null?void 0:e.message)||"注册失败"),i.value&&b()}).finally(()=>{f.value=!1}))})}function b(){M().then(t=>{i.value=(t==null?void 0:t.captchaEnabled)===void 0?!0:!!t.captchaEnabled,i.value?(h.value="data:image/gif;base64,"+(t.img||""),s.value.uuid=t.uuid||""):(s.value.code="",s.value.uuid="")}).catch(t=>{console.error("获取验证码失败:",t),i.value=!1,s.value.code="",s.value.uuid=""})}return b(),(t,e)=>{const n=u("svg-icon"),m=u("el-input"),c=u("el-form-item"),E=u("router-link"),C=u("el-button"),q=u("el-form");return g(),w("div",K,[e[8]||(e[8]=r("div",{class:"auth-bg"},null,-1)),r("div",S,[e[7]||(e[7]=T('<section class="brand-panel" data-v-c7ff50b3><div class="brand-badge" data-v-c7ff50b3>REGISTER</div><h1 data-v-c7ff50b3>先创建基础账号，再进入系统继续完善资料。</h1><p data-v-c7ff50b3> 当前注册页只提交后端稳定支持的最小注册参数，避免因为额外字段导致接口直接报错。 资料补全可以放到登录后再做。 </p><div class="feature-stack" data-v-c7ff50b3><div class="stack-card" data-v-c7ff50b3><span data-v-c7ff50b3>01</span><strong data-v-c7ff50b3>最小必填</strong><p data-v-c7ff50b3>只保留账号、密码、确认密码，以及按需出现的验证码。</p></div><div class="stack-card" data-v-c7ff50b3><span data-v-c7ff50b3>02</span><strong data-v-c7ff50b3>注册回流</strong><p data-v-c7ff50b3>注册成功后回到登录页，并自动带入你刚创建的账号。</p></div></div></section>',1)),r("section",$,[r("div",F,[e[6]||(e[6]=r("div",{class:"form-header"},[r("p",{class:"eyebrow"},"CREATE ACCOUNT"),r("h2",null,"创建账号"),r("p",{class:"desc"},"完成基础注册后，你就可以返回登录页进入系统。")],-1)),a(q,{ref_key:"registerRef",ref:v,model:o(s),rules:x,class:"auth-form"},{default:l(()=>[a(c,{prop:"username"},{default:l(()=>[a(m,{modelValue:o(s).username,"onUpdate:modelValue":e[0]||(e[0]=d=>o(s).username=d),size:"large",autocomplete:"off",clearable:"",placeholder:"账号"},{prefix:l(()=>[a(n,{"icon-class":"user",class:"el-input__icon input-icon"})]),_:1},8,["modelValue"])]),_:1}),a(c,{prop:"password"},{default:l(()=>[a(m,{modelValue:o(s).password,"onUpdate:modelValue":e[1]||(e[1]=d=>o(s).password=d),type:"password",size:"large",autocomplete:"off",placeholder:"密码","show-password":""},{prefix:l(()=>[a(n,{"icon-class":"password",class:"el-input__icon input-icon"})]),_:1},8,["modelValue"])]),_:1}),a(c,{prop:"confirmPassword"},{default:l(()=>[a(m,{modelValue:o(s).confirmPassword,"onUpdate:modelValue":e[2]||(e[2]=d=>o(s).confirmPassword=d),type:"password",size:"large",autocomplete:"off",placeholder:"确认密码","show-password":"",onKeyup:y(_,["enter"])},{prefix:l(()=>[a(n,{"icon-class":"password",class:"el-input__icon input-icon"})]),_:1},8,["modelValue"])]),_:1}),o(i)?(g(),U(c,{key:0,prop:"code"},{default:l(()=>[r("div",G,[a(m,{modelValue:o(s).code,"onUpdate:modelValue":e[3]||(e[3]=d=>o(s).code=d),size:"large",autocomplete:"off",clearable:"",placeholder:"验证码",onKeyup:y(_,["enter"])},{prefix:l(()=>[a(n,{"icon-class":"validCode",class:"el-input__icon input-icon"})]),_:1},8,["modelValue"]),r("img",{src:o(h),class:"captcha-img",onClick:b},null,8,H)])]),_:1})):z("",!0),r("div",L,[e[5]||(e[5]=r("span",null,"如果注册失败，会直接显示后端返回的错误信息。",-1)),a(E,{class:"action-link",to:"/login"},{default:l(()=>[...e[4]||(e[4]=[N("返回登录",-1)])]),_:1})]),a(c,null,{default:l(()=>[a(C,{loading:o(f),size:"large",type:"primary",class:"submit-btn register-btn",onClick:B(_,["prevent"])},{default:l(()=>[o(f)?(g(),w("span",j,"提交中...")):(g(),w("span",O,"创建账号"))]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])])])])}}},X=R(D,[["__scopeId","data-v-c7ff50b3"]]);export{X as default};
