import{_ as e}from"./index.vue_vue_type_script_setup_true_lang10.js?v=20260328163632";import{u as a,l as t,K as s,t as l,M as i,bo as n,x as u,v as o}from"./utils-lib.js?v=20260328163632";import{b8 as r,b9 as p}from"./site.js?v=20260328163632";import{u as c}from"./store4.js?v=20260328163632";import{k as d,c as m,r as v,O as y,o as f,V as h,W as b,X as x,l as _,Y as g,K as j,_ as k,a1 as w,F as R,U,u as A}from"./base-lib.js?v=20260328163632";import{N as O,au as E}from"./naive-ui.js?v=20260328163632";function T(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!A(e)}const L=d({__name:"index",props:{compData:{default:()=>{}}},setup(d,{expose:A}){const L=d,{siteInfo:N,siteType:S,isRefreshList:C}=c(),{isIIS:D,isAaPanel:I}=a(),K=m((()=>L.compData&&Array.isArray(L.compData)||!1)),P=v(!1),F=[{content:t("【URL后缀】一般填写文件后缀，每行一个后缀,如: png")},{content:t("【许可域名】允许作为来路的域名，每行一个域名,如: www.{0}",[I.value?"aapanel.com":"bt.cn"])},{content:t("【允许空HTTP_REFERER请求】是否允许浏览器直接访问，若您的网站访问异常，可尝试开启此功能")}],q={labelStyle:"min-width: 100px"},H=v({label:t("URL后缀"),attrs:q,ruleKey:"fix",rule:[s({message:t("请输入URL后缀")})],children:[{type:"input",key:"fix",attrs:{class:"!w-300px",placeholder:t("请输入URL后缀")}}]}),J=v({label:t("许可域名"),attrs:q,children:[{type:"input",key:"domains",attrs:{type:"textarea",class:"!w-300px",rows:5,placeholder:t("请输入许可域名")}}]}),W=v({label:t("是否追加域名"),attrs:q,children:[{type:"custom",key:"isAppend",render:()=>y(O,{checked:Q.value.isAppend,"onUpdate:checked":e=>Q.value.isAppend=e,onUpdateChecked:X},null)}]}),M=v({label:t("响应资源"),attrs:q,ruleKey:"return_code",rule:[s({message:t("请输入响应资源")})],children:[{type:"input",key:"return_code",attrs:{class:"!w-300px",placeholder:t("请输入响应资源"),disabled:D.value}}]}),V=v({label:" ",children:[{type:"custom",render:()=>{let e,a;return y(E,null,{default:()=>[y(O,{checked:Q.value.status,"onUpdate:checked":e=>Q.value.status=e,onUpdateChecked:X},T(e=t("启用防盗链"))?e:{default:()=>[e]}),y(O,{checked:Q.value.http_status,"onUpdate:checked":e=>Q.value.http_status=e,disabled:!Q.value.status},T(a=t("允许空HTTP_REFERER请求"))?a:{default:()=>[a]})]})}}]}),X=e=>{e||(Q.value.http_status=!1)},Y=async e=>{await Z.value.validate();const{fix:a,domains:s,return_code:l,...o}=Q.value;let p={siteid:N.value.id,...o,exts:JSON.stringify(null==a?void 0:a.split(",")),domains:JSON.stringify(null==s?void 0:s.split("\n"))};if(K.value){const a=i.load(t("正在设置防盗链，请稍后..."));let s=[];await Promise.all(L.compData.map((async(e,a)=>{try{const a=await r({...p,siteid:e.id});s.push({name:null==e?void 0:e.name,msg:a.msg,status:a.status})}catch(t){}}))),a.close(),n(s,{title:t("设置防盗链")}),e(),C.value=!0}else u({loading:t("正在设置防盗链，请稍后..."),request:r(p),success:$,message:!0})},z=v({label:" ",children:[{type:"button",key:"save",attrs:{type:"primary",buttonText:t("保存"),onClick:Y}}]}),B=v({formAttrs:{labelWidth:"auto"},formItems:m((()=>[H.value,J.value,...K.value?[W.value]:[],M.value,V.value,...K.value?[]:[z.value]]))}),[G,Q,Z]=l(B),$=async()=>{(Number(N.value.status)||!D.value||"php"!==S.value||K.value)&&(K.value?Object.assign(Q.value,{fix:"jpg,jpeg,gif,png,js,css",domains:"",return_code:"404",http_status:!1,status:!1,isAppend:!1}):u({loading:P,request:p({siteid:N.value.id}),success:e=>{const{domains:a,fix:t,...s}=e.data;Object.assign(Q.value,{domains:a.join("\n"),fix:t.join(","),...s})}}))};return f($),A({onConfirm:Y,init:$}),(a,t)=>{const s=U("bt-loading");return h(),b(R,null,[x("div",{class:j(g(K)?"p-20px":"")},[_(y(g(G),null,null,512),[[s,g(P)]]),y(g(o),{class:"mt-20px ml-20px",options:F})],2),Number(g(N).status)||!g(D)||"php"!==g(S)||g(K)?w("",!0):(h(),k(e,{key:0}))],64)}}});export{L as _};
