import{_ as R,b as P,r as p,d as i,o as g,g as w,i as r,C as T,k as a,f as l,l as o,m as V,e as U,j as N,n as z,h as B,p as M,E as y,q as I,Z as K}from"./index-Yv4yXRHK.js";const S={class:"auth-shell register-shell"},A={class:"auth-grid"},$={class:"form-panel"},j={class:"form-card register-card compact-card"},F={class:"captcha-row"},G=["src"],H={class:"helper-row"},L={key:0},O={key:1},Z={__name:"index",setup(D){const k=P(),v=p(null),f=p(!1),u=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){y.error("注册表单未初始化");return}v.value.validate(t=>{t&&(f.value=!0,I({username:s.value.username,password:s.value.password,code:s.value.code,uuid:s.value.uuid}).then(()=>{K.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=>{y.error((e==null?void 0:e.message)||"注册失败"),u.value&&b()}).finally(()=>{f.value=!1}))})}function b(){M().then(t=>{u.value=(t==null?void 0:t.captchaEnabled)===void 0?!0:!!t.captchaEnabled,u.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),u.value=!1,s.value.code="",s.value.uuid=""})}return b(),(t,e)=>{const n=i("svg-icon"),m=i("el-input"),c=i("el-form-item"),C=i("router-link"),E=i("el-button"),q=i("el-form");return g(),w("div",S,[e[8]||(e[8]=r("div",{class:"auth-bg"},null,-1)),r("div",A,[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",j,[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:V(_,["enter"])},{prefix:l(()=>[a(n,{"icon-class":"password",class:"el-input__icon input-icon"})]),_:1},8,["modelValue"])]),_:1}),o(u)?(g(),U(c,{key:0,prop:"code"},{default:l(()=>[r("div",F,[a(m,{modelValue:o(s).code,"onUpdate:modelValue":e[3]||(e[3]=d=>o(s).code=d),size:"large",autocomplete:"off",clearable:"",placeholder:"验证码",onKeyup:V(_,["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,G)])]),_:1})):N("",!0),r("div",H,[e[5]||(e[5]=r("span",null,"如果注册失败，会直接显示后端返回的错误信息。",-1)),a(C,{class:"action-link",to:"/login"},{default:l(()=>[...e[4]||(e[4]=[z("返回登录",-1)])]),_:1})]),a(c,null,{default:l(()=>[a(E,{loading:o(f),size:"large",type:"primary",class:"submit-btn register-btn",onClick:B(_,["prevent"])},{default:l(()=>[o(f)?(g(),w("span",O,"提交中...")):(g(),w("span",L,"创建账号"))]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])])])])}}},W=R(Z,[["__scopeId","data-v-c7ff50b3"]]);export{W as default};
