2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
import{d as E,r as y,a as R,v as z,o as j,g as n,J as q,K as A,z as D,k as i,w as o,e as a,H as U,b as s,t as d,c as v,x as H,l as J,Q as K,E as u,_ as O}from"./index-DwwVE1Ec.js";import{t as P,v as Q}from"./config-AGmWPlik.js";const T={class:"card-header"},F={class:"form-tip"},G={key:0},L={key:1},W={key:2},X={class:"uid-preview"},Y=E({__name:"UserConfigCard",setup(Z){const _=y(!1),p=y(!1),m=y(),t=R({uid_type:"1",uid_length:8}),I=z(()=>{if(t.uid_type==="1")return"10001";if(t.uid_type==="2")return"0".repeat(t.uid_length).replace(/0/g,()=>String(Math.floor(Math.random()*10)));{const l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let r=0;r<t.uid_length;r++)e+=l.charAt(Math.floor(Math.random()*l.length));return e}}),h={uid_type:[{required:!0,message:"请选择UID类型",trigger:"change"}],uid_length:[{type:"number",min:6,max:20,message:"UID长度必须在6-20之间",trigger:"blur"}]},b=async()=>{var l;_.value=!0;try{const e=await P();if((l=e.data)!=null&&l.value){const r=e.data.value;Object.assign(t,{uid_type:r.uid_type||"1",uid_length:Number(r.uid_length)||8})}}catch(e){u.error("加载用户UID设置失败"),console.error("加载用户UID设置失败:",e)}finally{_.value=!1}},w=async()=>{if(m.value){try{await m.value.validate()}catch{u.warning("请检查表单填写是否正确");return}p.value=!0;try{const l={uid_type:t.uid_type,uid_length:String(t.uid_length)};await Q(l),u.success("保存成功")}catch(l){u.error("保存失败"),console.error("保存用户UID设置失败:",l)}finally{p.value=!1}}};return j(()=>{b()}),(l,e)=>{const r=n("el-icon"),k=n("el-button"),x=n("el-alert"),f=n("el-radio"),C=n("el-radio-group"),c=n("el-form-item"),V=n("el-input-number"),M=n("el-tag"),S=n("el-form"),N=n("el-card"),B=q("loading");return A((i(),D(N,null,{header:o(()=>[s("div",T,[e[3]||(e[3]=s("span",null,"用户UID设置",-1)),a(k,{type:"primary",loading:p.value,onClick:w},{default:o(()=>[a(r,null,{default:o(()=>[a(J(K))]),_:1}),e[2]||(e[2]=d("保存配置 ",-1))]),_:1},8,["loading"])])]),default:o(()=>[a(S,{ref_key:"formRef",ref:m,model:t,rules:h,"label-width":"120px",class:"config-form"},{default:o(()=>[a(x,{title:"UID设置说明",type:"info",closable:!1,"show-icon":"",style:{"margin-bottom":"20px"}},{default:o(()=>[...e[4]||(e[4]=[s("p",null,"配置新用户注册时生成的UID格式。修改后仅对新注册用户生效。",-1)])]),_:1}),a(c,{label:"UID类型",prop:"uid_type"},{default:o(()=>[a(C,{modelValue:t.uid_type,"onUpdate:modelValue":e[0]||(e[0]=g=>t.uid_type=g)},{default:o(()=>[a(f,{value:"1"},{default:o(()=>[...e[5]||(e[5]=[d("真实ID",-1)])]),_:1}),a(f,{value:"2"},{default:o(()=>[...e[6]||(e[6]=[d("数字ID",-1)])]),_:1}),a(f,{value:"3"},{default:o(()=>[...e[7]||(e[7]=[d("随机字符和数字",-1)])]),_:1})]),_:1},8,["modelValue"]),s("div",F,[t.uid_type==="1"?(i(),v("span",G,"使用数据库自增ID作为用户UID")):t.uid_type==="2"?(i(),v("span",L,"生成指定长度的纯数字UID")):t.uid_type==="3"?(i(),v("span",W,"生成指定长度的字母数字混合UID")):U("",!0)])]),_:1}),t.uid_type!=="1"?(i(),D(c,{key:0,label:"UID长度",prop:"uid_length"},{default:o(()=>[a(V,{modelValue:t.uid_length,"onUpdate:modelValue":e[1]||(e[1]=g=>t.uid_length=g),modelModifiers:{number:!0},min:6,max:20,placeholder:"请输入UID长度",style:{width:"200px"}},null,8,["modelValue"]),e[8]||(e[8]=s("div",{class:"form-tip"},"UID长度范围:6-20位",-1))]),_:1})):U("",!0),a(c,{label:"UID预览"},{default:o(()=>[s("div",X,[a(M,{type:"info",size:"large"},{default:o(()=>[d(H(I.value),1)]),_:1})]),e[9]||(e[9]=s("div",{class:"form-tip"},"示例UID格式预览",-1))]),_:1})]),_:1},8,["model"])]),_:1})),[[B,_.value]])}}}),te=O(Y,[["__scopeId","data-v-92a6d76b"]]);export{te as default};
|