File: /www/server/panel/BTPanel/static/js/useController11.js
import{k as y,w as L,e as F,_ as C,cN as V,f as j}from"./utils-lib.js?v=1777008528";import{delProxyUrlReplace as H,getProxyUrlData as A,editProxyUrlDataRemark as O,delProxyUrlData as S,addProxyUrlData as M,editProxyUrlInfo as W,addProxyUrlReplace as X,proxyUrlCache as Z,proxyUrlCompress as G,proxyUrlBatchDelLimit as J,proxyUrlDelLimit as I,proxyUrlAddLimit as K}from"./site.js?v=1777008528";import{r as a,H as d,g as Q,e as x,aW as Y,x as E}from"./base-lib.js?v=1777008528";import{g as T,e as ee,w as k,b as te}from"./index3.js?v=1777008528";import{u as se}from"./useStore2.js?v=1777008528";const U=j(),{siteInfo:u}=se(),q=a({}),P=a(!1),De=[{content:"支持添加多个不同目录的代理"},{content:"如添加后访问异常请尝试清理浏览器缓存"}],Fe=async()=>{try{const e=await y({request:A({site_name:u.value.name}),data:{data:Array}});return Array.isArray(e.data)?{data:e.data,total:e.data.length}:{data:[],total:0}}catch(e){return{data:[],total:0}}},Ce=()=>{F({isAsync:!0,title:"添加URL代理",area:60,btn:"确认",component:()=>C(()=>import("./add-url-proxy.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},Re=async(e,t)=>{y({loading:"正在修改URL代理备注,请稍后...",request:O({site_name:u.value.name,proxy_path:e.proxy_path,remark:t}),message:!0})},Le=e=>{q.value=e,F({isAsync:!0,title:"URL代理设置【".concat(e.proxy_path,"】"),area:[76,60],component:()=>C(()=>import("./setting.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{row:e}})},Ae=async e=>{if(e.proxy_path==="/"){U.error("根目录不能删除");return}await L({title:"删除反向代理【".concat(e.proxy_path,"】"),width:"35rem",icon:"warning-filled",content:"您真的要删除反向代理【".concat(e.proxy_path,"】吗?")}),(await y({loading:"正在删除,请稍后...",request:S({site_name:u.value.name,proxy_path:e.proxy_path}),message:!0})).status&&(P.value=!0)},Ie=[{content:"目标:可以填写你需要代理的站点,目标如果选URL地址则必须为可正常访问的URL,如果选UNIX则必须是套接字文件"},{content:"http地址示例:http://127.0.0.1:15700"},{content:"unix地址示例:/tmp/panel.sock"},{content:()=>x("span",null,[E("发送域名:将域名添加到请求头传递到后端服务器,默认为目标URL域名,若设置不当可能导致代理无法正常访问,例如:"),x("br",null,null),E("http://192.168.100.20:19888,则发送域名保持$http_host即可"),x("br",null,null),E("http://www.bt.cn,则发送域名应当改为www.bt.cn"),x("br",null,null),E("上面例子仅为常见情况,请以实际为准")])}],Te=[{label:"URL地址",value:"http"},{label:"UNIX地址",value:"unix"}],ke=()=>{k({type:"file",path:n.proxysite||"/www",change:e=>{n.proxysite=e}})},l=d({targetType:"http",sitename:"",cachetime:1,proxysite:"http://",todomain:"$http_host",path:"",ps:"",websocket:!1}),Ue=a(!1),qe=a(!1),f=a(!1),B=a(),Pe=d({proxyname:[{required:!0,message:"请输入代理名称",trigger:"blur"},{validator:(e,t,s)=>{t.length<3?s(new Error("代理名称必须大于3个字符串")):t.match(/^[a-zA-Z0-9_.-]+$/g)?s():s(new Error("代理名称不能包含特殊字符"))}}],proxysite:[{required:!0,message:"请输入目标地址",trigger:"blur"},{validator:(e,t,s)=>{if(!t){s(new Error(l.targetType==="http"?"目标地址不能为空":"请选择sock文件"));return}if(l.targetType==="unix"){s();return}const r=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;let o=t.replace(/^http[s]?:\/\//,"");o=o.replace(/(:|\?|\/|\\)(.*)$/,""),r.test(o)?l.todomain="$http_host":l.todomain=o,s()}},{}],todomain:[{required:!0,message:"请输入发送域名",trigger:["blur","change"]}],path:[{required:!0,message:"请输入根目录",trigger:"blur"}]}),Be=async()=>{l.proxysite=l.targetType==="http"?"http://":""},Ne=e=>{if(l.targetType==="unix"){l.todomain="$http_host";return}let t=e.replace(/^http[s]?:\/\//,"");t=t.replace(/(:|\?|\/|\\)(.*)$/,""),l.todomain=t},ze=e=>{if(n.targetType==="unix"){n.todomain="$http_host";return}let t=e.replace(/^http[s]?:\/\//,"");t=t.replace(/(:|\?|\/|\\)(.*)$/,""),n.todomain=t},Ve=()=>{k({type:"file",path:l.proxysite,change:e=>{l.proxysite=e}})},je=async()=>{const{path:e,proxysite:t,todomain:s,targetType:r,ps:o}=l;let i={site_name:u.value.name,proxy_path:e,proxy_pass:t,proxy_host:s,proxy_type:r,remark:o};await B.value.validate();const h=await y({loading:f,request:M(i),message:!0});return h.status&&(P.value=!0),h.status},R=a("proxy"),p=a({proxy_type:"",proxy_path:"",proxy_pass:"",proxy_host:"$http_host",ip_limit:{},basic_auth:{},proxy_cache:{},gzip:{},sub_filter:{},websocket:{},proxy_log:{},custom_config:[],security_referer:{},proxy_conf:"",remark:"",template_proxy_conf:""}),v=async()=>{try{const e=await A({site_name:u.value.name,proxy_path:q.value.proxy_path});if(!e.status){U.error(e.msg);return}p.value=e.data.data}catch(e){}},ae=a(!1),n=d({targetType:"http",sitename:"",proxysite:"",todomain:"$http_host",path:"",ps:"",websocket:!1,proxy_connect_timeout:30,proxy_send_timeout:30,proxy_read_timeout:30}),He=Q(()=>({proxysite:[{required:!0,message:n.targetType!=="http"?"请选择sock文件":"请输入目标url",trigger:"blur",validator:(e,t,s)=>{t?s():s(new Error(n.targetType!=="http"?"请选择sock文件":"请输入目标url"))}}],todomain:[{required:!0,message:"请输入发送域名",trigger:["blur","change"]}],proxy_connect_timeout:[{required:!0,message:"请输入连接超时时间",trigger:["blur","change"],validator:(e,t,s)=>{t?isNaN(Number(t))?s(new Error("请输入数字")):s():s(new Error("连接超时时间不能为空"))}}],proxy_send_timeout:[{required:!0,message:"请输入后端请求超时时间",trigger:["blur","change"],validator:(e,t,s)=>{t?isNaN(Number(t))?s(new Error("请输入数字")):s():s(new Error("后端请求超时时间不能为空"))}}],proxy_read_timeout:[{required:!0,message:"请输入代理响应超时时间",trigger:["blur","change"],validator:(e,t,s)=>{t?isNaN(Number(t))?s(new Error("请输入数字")):s():s(new Error("代理响应超时时间不能为空"))}}]})),Oe=e=>{const{proxy_type:t,proxy_pass:s,proxy_host:r,proxy_path:o,remark:i,global_websocket:h,websocket:w,timeout:c}=e;n.targetType=t,n.proxysite=s,n.todomain=r,n.path=o,n.ps=i,ae.value=h,n.websocket=w==null?void 0:w.websocket_status,n.proxy_connect_timeout=c==null?void 0:c.proxy_connect_timeout,n.proxy_send_timeout=c==null?void 0:c.proxy_send_timeout,n.proxy_read_timeout=c==null?void 0:c.proxy_read_timeout},Se=async()=>{const{path:e,proxysite:t,todomain:s,targetType:r,ps:o,websocket:i,proxy_connect_timeout:h,proxy_send_timeout:w,proxy_read_timeout:c}=n,z={site_name:u.value.name,proxy_path:e,proxy_pass:t,proxy_host:s,proxy_type:r,remark:o,websocket:i?1:0,proxy_connect_timeout:h,proxy_send_timeout:w,proxy_read_timeout:c};return await B.value.validate(),(await y({loading:f,request:W(z),message:!0})).status};d({config:""});const re=d({subfilter:[]}),Me=[{content:"规则解释如下"},{content:"g:替换所有匹配到的关键字"},{content:"i:不区分大小写"},{content:"o:只替换匹配到的第一个"},{content:"r:使用正则表达式"}],oe=()=>a([{label:"原关键词",prop:"oldstr"},{label:"替换词",prop:"newstr"},{label:"规则",prop:"mode",width:50,render:e=>x(Y,{class:"item",effect:"dark","open-delay":500,content:ie(e),placement:"top-start"},{default:()=>[x("div",{class:"flex items-center"},["".concat(e.sub_type)])]})},T([{title:"删除",onClick:e=>{ne(e)}}])]),ne=async e=>{await y({loading:"正在删除,请稍后...",request:H({site_name:u.value.name,proxy_path:p.value.proxy_path,oldstr:e.oldstr,newstr:e.newstr}),message:!0}),v()},ie=e=>{const t=[e.oldstr,e.newstr],s=e.sub_type.replace(/g/g,""),r=s.includes("i")?"不区分大小写":"",o=s.includes("o")?"只替换第一个":"",i=s.includes("r")?"使用正则表达式":"";switch(s.length){case 0:return"效果:将全部'".concat(t[0],"'替换为'").concat(t[1],"''");case 1:return"效果:将".concat(o?"":"全部","'").concat(t[0],"'替换为'").concat(t[1],"',匹配时").concat(r||o||i);case 2:return"效果:将".concat(o?"":"全部","'").concat(t[0],"'替换为'").concat(t[1],"',匹配时").concat(r||o||i,"并且").concat(i||o||r);case 3:return"效果:将'".concat(t[0],"'替换为'").concat(t[1],"',匹配时").concat(r,"、").concat(o,"并且").concat(i)}},We=e=>{try{re.subfilter=e.sub_filter_str}catch(t){}},Xe=oe(),Ze=()=>{Object.assign(m,{oldstr:"",newstr:""}),D.value=[],b.value="默认效果:将全部'http://www.bt.cn'替换为'https://www.bt.cn'",F({isAsync:!0,title:"添加内容替换【".concat(p.value.proxy_path,"】"),area:60,btn:"确认",component:()=>C(()=>import("./setting-replace-add.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{proxy_path:p.value.proxy_path,subs_filter:p.value.subs_filter}})},m=d({oldstr:"",newstr:""}),Ge={oldstr:[V({message:"请输入原关键词"})]},D=a([]),b=a("默认效果:将全部'http://www.bt.cn'替换为'https://www.bt.cn'"),pe=a(),Je=e=>{ue(D.value)},ue=e=>{const t=e.includes("i")?"不区分大小写":"",s=e.includes("o")?"只替换第一个":"",r=e.includes("r")?"使用正则表达式":"";switch(e.length){case 0:b.value="默认效果:将全部".concat(m.oldstr,"替换为").concat(m.newstr);break;case 1:b.value="效果:将".concat(s?"":"全部").concat(m.oldstr,"替换为").concat(m.newstr,",匹配时").concat(t||s||r);break;case 2:b.value="效果:将".concat(s?"":"全部").concat(m.oldstr,"替换为").concat(m.newstr,",匹配时").concat(t||s||r,"并且").concat(r||s||t);break;case 3:b.value="效果:将".concat(m.oldstr,"替换为").concat(m.newstr,",匹配时").concat(t,"、").concat(s,"并且").concat(r);break}},Ke=async()=>{await pe.value.validate();const e={site_name:u.value.name,oldstr:m.oldstr,newstr:m.newstr,proxy_path:p.value.proxy_path,sub_type:D.value.length?D.value.join(""):"g"},t=await y({loading:f,request:X(e),message:!0});return t.status&&v(),t.status},le=a(),$=d({status:!1,time:"1",unit:"d",cache_suffix:"css,js,jpg,jpeg,gif,png,webp,woff,eot,ttf,svg,ico,css.map,js.map"}),Qe=[{label:"分钟",value:"m"},{label:"小时",value:"h"},{label:"天",value:"d"}],Ye=[{content:"缓存是一种用于加速网站性能和提高用户体验的技术"},{content:"开启后资源会被缓存,如果影响网站访问请关闭"},{content:"缓存键由主机名、URI 和请求参数组成"},{content:"默认忽略的响应头有:Set-Cookie|Cache-Control|expires|X-Accel-Expires"},{content:"默认缓存的静态资源有:css|js|jpg|jpeg|gif|png|webp|woff|eot|ttf|svg|ico|css.map|js.map"}],et=e=>{ce()},ce=async()=>{const e={site_name:u.value.name,proxy_path:p.value.proxy_path,cache_status:$.status?1:0,expires:"".concat($.time).concat($.unit),cache_suffix:$.cache_suffix.replace(/,/g,",")};return await le.value.validate(),(await y({loading:f,request:Z(e),message:!0})).status},me=a(),_=d({status:!1,type:"",level:1,minLength:"",unit:"m"}),tt=[{label:"k",value:"k"},{label:"m",value:"m"}],st=[{content:"用于对 HTTP 响应的内容进行压缩,以减少数据传输量,提高网站性能和加载速度"},{content:"压缩级别1-9,例如:1为压缩速度最快,但压缩率较低;9为压缩速度最慢,但压缩率最高,建议默认"},{content:"如果开启gzip后影响网站正常访问,请关闭此功能 和请求参数组成"}],at={type:[{required:!0,message:"请输入压缩类型",trigger:["blur","change"]}],minLength:[{required:!0,message:"请输入正确的压缩最小长度",trigger:"blur",validator:(e,t,s)=>{t?isNaN(Number(t))?s(new Error("请输入数字")):Number(t)<1?s(new Error("请输入正确数字")):s():s(new Error("压缩最小长度不能为空"))}},{}]},rt=e=>{_.status=e.gzip_status,_.type=e.gzip_types,_.level=e.gzip_comp_level;let t="",s="m";e.gzip_min_length&&e.gzip_min_length.length>1&&(t=e.gzip_min_length.slice(0,-1),s=e.gzip_min_length.slice(-1)),_.minLength=t,_.unit=s},ot=e=>{ye()},ye=async()=>{const e={site_name:u.value.name,proxy_path:p.value.proxy_path,gzip_status:_.status?1:0,gzip_min_length:"".concat(_.minLength).concat(_.unit),gzip_comp_level:_.level,gzip_types:_.type};return await me.value.validate(),(await y({loading:f,request:G(e),message:!0})).status},nt=a(),it=a(),g=d({loading:!1,type:"black",white:[],black:[]}),_e=()=>a([ee({key:"ip"}),{label:"IP",prop:"ip",minWidth:120},T([{title:"删除",onClick:e=>{he(e)}}])]),de=e=>{g.white=e.ip_white.map(t=>({ip:t,type:"white"})),g.black=e.ip_black.map(t=>({ip:t,type:"black"}))},he=async e=>{const t=!!Array.isArray(e);await L({title:"".concat(t?"批量删除":"删除").concat(g.type==="white"?"白":"黑","名单"),content:"".concat(t?"批量删除选中的ip,是否继续操作?":"删除".concat(g.type==="white"?"白":"黑","名单【").concat(e.ip,"】,是否继续操作?"))});let s={site_name:u.value.name,proxy_path:p.value.proxy_path};t?(s.ips=e.map(i=>i.ip).join("\n"),s.ip_type=g.type):(s.ip=e.ip,s.ip_type=e.type),(await y({loading:"正在删除,请稍后...",request:(t?J:I)(s),message:!0})).status&&v()},ge=()=>[{label:"删除IP",value:"delete",event:async(e,t,s,r,o)=>{const i=async h=>await I({site_name:u.value.name,proxy_path:p.value.proxy_path,ip:h.ip,ip_type:R.value==="ipBlackList"?"black":"white"});await e({title:"批量删除",content:"批量删除选中的ip,是否继续操作?",column:[{prop:"ip",label:"IP"},te()],onConfirm:async()=>(await t(i),v(),!1)})}}],pt=_e(),ut=ge(),lt=()=>{g.type=R.value==="ipBlackList"?"black":"white",de(p.value.ip_limit)},ct=()=>{N.value.address="",F({isAsync:!0,title:"添加IP".concat(R.value==="ipBlackList"?"黑":"白","名单【").concat(p.value.proxy_path,"】"),area:40,btn:"确认",component:()=>C(()=>import("./setting-ip-add.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{name:u.value.name,proxy_path:p.value.proxy_path,listType:g.type,refreshEvent:()=>{v()}}})},N=a({types:g.type,address:""}),xe=a(),mt=[{content:"一行一条配置,多个IP请换行"}],yt={address:[{validator:(e,t,s)=>{t.length>0?s():s(new Error("请输入IP地址"))},trigger:["blur","change"]}]},_t=async()=>{const{address:e}=N.value,t={site_name:u.value.name,proxy_path:p.value.proxy_path,ip_type:R.value==="ipBlackList"?"black":"white",ips:e};await xe.value.validate();const s=await y({loading:f,request:K(t),message:!0});return s.status&&v(),s.status};export{ot as $,Ce as A,Fe as B,Re as C,Le as D,Ae as E,De as F,P as G,Oe as H,n as I,ze as J,ke as K,ae as L,Se as M,He as N,We as O,Ze as P,re as Q,Xe as R,Me as S,$ as T,et as U,Qe as V,ce as W,le as X,Ye as Y,rt as Z,_,Ve as a,tt as a0,ye as a1,me as a2,at as a3,st as a4,de as a5,g as a6,R as a7,it as a8,nt as a9,ct as aa,lt as ab,pt as ac,ut as ad,v as ae,B as b,Pe as c,f as d,Ie as e,qe as f,Ke as g,Ne as h,m as i,Je as j,p as k,ue as l,b as m,pe as n,je as o,Ue as p,Ge as q,D as r,Be as s,Te as t,l as u,_t as v,N as w,mt as x,xe as y,yt as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = []
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}