import{c as e,o as a,r as s,v as t,x as l,e as r,B as d,z as o,y as m,C as i,ab as u,b1 as p,G as n,a9 as c}from"./base-lib.js?v=1761009159";import{an as _,p as b,P as f,k as g,_ as w}from"./utils-lib.js?v=1761009159";import{u as h}from"./column.js?v=1761009159";import{setPassUserApi as V}from"./site.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";const y={class:"p-[20px]"},x={class:"flex items-center"},D=w(e({__name:"edit-pass-limit",props:{compData:{default:()=>({})}},emits:["close"],setup(e,{emit:w}){const D=e,j=w,v=a({site_dir:D.compData.site_dir||"",name:D.compData.name||"",username:D.compData.username||"",password:D.compData.password||""}),k=s(!1),q=s(),U=a({username:[{required:!0,message:"请输入用户名",trigger:"blur"},{min:3,message:"用户名必须大于三位",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"},{min:3,message:"密码必须大于三位",trigger:"blur"}]}),{BtTable:C,config:B}=_({request:()=>{const e=D.compData.user_list.map(e=>({user:e}))||[];return{data:e,total:e.length}},columns:[{prop:"user",label:"用户"},h([{title:"删除",onClick:e=>z("remove",e)}])]}),z=async(e,a)=>{const s=B.data.some(e=>e.user===v.username);s&&"add"===e&&await b({title:"提示",content:"用户已存在，继续添加会覆盖同名用户配置，是否继续？"}),1===B.data.length&&"remove"===e&&await b({title:"提示",content:"确认删除用户【".concat(B.data[0].user,"】？此为当前唯一用户，删除后该加密规则将一起被删除，是否继续？")});let t={id:D.compData.id,...v,username:a?a.user:v.username,option:e};delete t.site_dir,f({loading:"正在".concat({add:"添加",remove:"删除"}[e],"，请稍后..."),request:V(t),message:!0,success:t=>{t.status&&("add"===e?(!s&&B.data.push({user:v.username}),v.username="",v.password=""):(B.data=B.data.filter(e=>e.user!==a.user),0===B.data.length&&j("close")),D.compData.refresh())}})};return(e,a)=>{const s=g,_=u,b=p,f=n,w=c;return t(),l("div",y,[r(w,{ref_key:"passwordSiteForm",ref:q,rules:m(U),model:m(v),disabled:m(k)},{default:d(()=>[o("div",x,[r(_,{label:"加密路径",prop:"site_dir"},{default:d(()=>[r(s,{disabled:!!e.compData.name,modelValue:m(v).site_dir,"onUpdate:modelValue":a[0]||(a[0]=e=>m(v).site_dir=e),placeholder:"输入需要加密访问的目录，如：/text/",width:"13rem"},null,8,["disabled","modelValue"])]),_:1}),r(_,{label:"名称",prop:"name"},{default:d(()=>[r(s,{modelValue:m(v).name,"onUpdate:modelValue":a[1]||(a[1]=e=>m(v).name=e),disabled:!!e.compData.name,width:"13rem"},null,8,["modelValue","disabled"])]),_:1})]),r(b,{"border-style":"dashed",class:"!mt-0"}),r(_,{label:"新用户",prop:"username"},{default:d(()=>[r(s,{modelValue:m(v).username,"onUpdate:modelValue":a[2]||(a[2]=e=>m(v).username=e),placeholder:"请输入大于三位的用户名",width:"26rem"},null,8,["modelValue"]),r(f,{type:"primary",onClick:a[3]||(a[3]=e=>z("add")),class:"ml-[8px]"},{default:d(()=>a[5]||(a[5]=[i(" 添加 ",-1)])),_:1,__:[5]})]),_:1}),r(_,{label:"密码",prop:"password"},{default:d(()=>[r(s,{modelValue:m(v).password,"onUpdate:modelValue":a[4]||(a[4]=e=>m(v).password=e),type:"password",placeholder:"请输入大于三位的密码",width:"26rem"},null,8,["modelValue"])]),_:1}),r(b,{"border-style":"dashed"}),r(_,{label:"已有用户",prop:"password"},{default:d(()=>[r(m(C),{class:"!w-[85%]"})]),_:1}),a[6]||(a[6]=o("ul",{class:"ml-6 mt-8 list-disc leading-10"},[o("li",{class:"text-secondary"},"目录设置加密访问后，会导致目录及子目录下的“反向代理”失效"),o("li",{class:"text-secondary"},"目录设置加密访问后，访问时需要输入账号密码才能访问"),o("li",{class:"text-secondary"},"例如我设置了加密访问 /test/ ,那我访问 http://aaa.com/test/ 时就要输入账号密码才能访问")],-1))]),_:1,__:[6]},8,["rules","model","disabled"])])}}}),[["__scopeId","data-v-ddb04fec"]]);export{D as default};
