import{M as e,P as t,aK as a,k as s,$ as l}from"./utils-lib.js?v=1761009159";import{r,g as u,o,w as n,c as i,q as p,H as d,I as m,y as _,v as c,x as f,e as g,B as v,C as j,N as x,D as h,ab as y,U as b,G as V,a9 as w}from"./base-lib.js?v=1761009159";import{batchPhpReferer as R,setProxyAntiLeech as C,setSecurity as U,getSecurity as E}from"./site.js?v=1761009159";import{o as L}from"./useController6.js?v=1761009159";import{u as k}from"./useStore4.js?v=1761009159";import{h as H,i as P}from"./validator.js?v=1761009159";import{p as q}from"./useController14.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";const{siteInfo:D,isRefreshList:T}=k(),F=r(),S=u(()=>{var e,t,a;return Array.isArray(null==(e=F.value)?void 0:e.selectedList)&&(null==(a=null==(t=F.value)?void 0:t.selectedList)?void 0:a.length)>0}),A=r(!1),I=o({fix:"jpg,jpeg,gif,png,js,css",domains:"",return_rule:"404",http_status:!1,status:!1}),z=r(null),B=[{content:'【URL后缀】一般填写文件后缀,每个文件后缀使用","分隔,如: png,jpg'},{content:"【许可域名】允许作为来路的域名，每行一个域名,如: www.bt.cn"},{content:"【响应资源】可设置404/403等状态码，也可以设置一个有效资源，如：/security.png"},{content:"【允许空HTTP_REFERER请求】是否允许浏览器直接访问，若您的网站访问异常，可尝试开启此功能"}],G=t=>{if(!I.status)return e.error("请先启用防盗链!")},K=e=>{I.status=e,e||(I.http_status=!1)},M=async e=>{var a;await z.value.validate();let s={...I,domains:null==(a=I.domains)?void 0:a.replace(/\n/g,",")};if(S.value){const{enable:e,exclude:t}=F.value.config,a=H(F.value.selectedList,t,e,{params:{project_type:"PHP"}});s={...s,...a}}else s.id=D.value.id,s.site_name=D.value.name;const l=S.value?R:"proxy"===D.value.project_type?C:U,r=await t({loading:"正在设置防盗链，请稍后...",request:l({...s,..."proxy"===D.value.project_type?{proxy_path:q.value.proxy_path}:{}}),message:!S.value});if(S.value){const{data:t}=P(r.data);L({resultData:t,title:"批量设置防盗链"}),T.value=!0,$(),e&&e()}else N(F.value)},N=async e=>{var t,s;if(F.value=e||[],S.value&&$(),"proxy"!==D.value.project_type){if(!e){const{id:e,name:r}=D.value;try{A.value=!0;const{data:a}=await E({id:e,site_name:r});a&&(I.fix=a.fix||"jpg,jpeg,gif,png,js,css",I.domains=(null==(s=null==(t=a.domains)?void 0:t.toString())?void 0:s.replace(/,/g,"\n"))||"",I.return_rule=a.return_rule||"404",I.http_status=a.http_status||!1,I.status=a.status||!1)}catch(l){a(l)}finally{A.value=!1}}}else n(()=>q.value.security_referer,e=>{var t,a;I.fix=e.fix||"jpg,jpeg,gif,png,js,css",I.domains=(null==(a=null==(t=e.domains)?void 0:t.toString())?void 0:a.replace(/,/g,"\n"))||"",I.return_rule=e.return_rule||"404",I.http_status=e.http_status||!1,I.status=e.status||!1})},$=()=>{I.fix="jpg,jpeg,gif,png,js,css",I.domains="",I.return_rule="404",I.http_status=!1,I.status=!1},J={fix:[{required:!0,message:"请输入url后缀",trigger:"blur"}],return_rule:[{required:!0,message:"请输入响应资源",trigger:"blur"}]},O={class:"p-[20px]"},Q=i({__name:"index",props:{compData:{default:()=>{}}},emits:["close"],setup(e,{expose:t,emit:a}){const r=e,u=()=>{N(r.compData)};return p(u),t({onConfirm:M,init:u}),(e,t)=>{const a=s,r=y,u=b,o=V,n=w,i=l,p=d("bt-loading");return m((c(),f("div",O,[g(n,{ref_key:"hotFormRef",ref:z,model:_(I),rules:_(J)},{default:v(()=>[g(r,{label:"URL后缀",prop:"fix"},{default:v(()=>[g(a,{modelValue:_(I).fix,"onUpdate:modelValue":t[0]||(t[0]=e=>_(I).fix=e),width:"30rem"},null,8,["modelValue"])]),_:1}),g(r,{label:"许可域名"},{default:v(()=>[g(a,{width:"30rem",modelValue:_(I).domains,"onUpdate:modelValue":t[1]||(t[1]=e=>_(I).domains=e),type:"textarea",resize:"none",rows:8,placeholder:"默认添加主域名，可追加其他的允许域名，一行一个，可为空"},null,8,["modelValue"])]),_:1}),g(r,{label:"响应资源",prop:"return_rule"},{default:v(()=>[g(a,{width:"30rem",modelValue:_(I).return_rule,"onUpdate:modelValue":t[2]||(t[2]=e=>_(I).return_rule=e)},null,8,["modelValue"])]),_:1}),g(r,{label:" "},{default:v(()=>[g(u,{modelValue:_(I).status,"onUpdate:modelValue":t[3]||(t[3]=e=>_(I).status=e),onChange:_(K)},{default:v(()=>t[6]||(t[6]=[j("启用防盗链",-1)])),_:1,__:[6]},8,["modelValue","onChange"]),g(u,{disabled:!_(I).status,title:"".concat(_(I).status?"":"需开启防盗链"),modelValue:_(I).http_status,"onUpdate:modelValue":t[4]||(t[4]=e=>_(I).http_status=e),onChange:_(G)},{default:v(()=>t[7]||(t[7]=[j(" 允许空HTTP_REFERER请求 ",-1)])),_:1,__:[7]},8,["disabled","title","modelValue","onChange"])]),_:1}),_(S)?h("",!0):(c(),x(r,{key:0,label:" "},{default:v(()=>[g(o,{type:"primary",onClick:t[5]||(t[5]=e=>_(M)())},{default:v(()=>t[8]||(t[8]=[j("保存",-1)])),_:1,__:[8]})]),_:1}))]),_:1},8,["model","rules"]),_(S)?h("",!0):(c(),x(i,{key:0,options:_(B),class:"ml-[20px] mt-[20px]"},null,8,["options"]))])),[[p,_(A)]])}}});export{Q as default};
