← Back
Editing: index430.js
import{jk as t,n as e,L as a,K as s,jl as o,p as r,jm as n,jn as l,at as i,jo as p,jp as c,bV as u,jq as _,jr as m,js as y,jt as d,ju as h,b as g,jv as x,jw as w,jx as v,aM as b,fj as k,a7 as f,W as j}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as q}from"./index103.js?v=VERSION_NUMBER";import{r as E,e as T,B as z,k as A,g as L,F as N,aQ as $,c as I,q as P,v as C,A as R,x as O}from"./base-lib.js?v=VERSION_NUMBER";import{u as U,a as D,g as B}from"./column.js?v=VERSION_NUMBER";import{f as V}from"./validator.js?v=VERSION_NUMBER";import{n as S}from"./useController4.js?v=VERSION_NUMBER";const W=g(),{siteInfo:M}=S(),X=E({}),F=E(!1),H=[{content:"支持添加多个不同目录的代理"},{content:"如添加后访问异常请尝试清理浏览器缓存"}],K=async()=>{try{const{data:e}=await t({site_name:M.value.name});return Array.isArray(e.data)?{data:e.data,total:e.data.length}:{data:[],total:0}}catch(e){return{data:[],total:0}}},Q=()=>{e({isAsync:!0,title:"添加反向代理",area:60,btn:"确认",component:()=>a((()=>import("./add-url-proxy.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)})},Z=async(t,e)=>{s({loading:"正在修改反向代理备注,请稍后...",request:o({site_name:M.value.name,proxy_path:t.proxy_path,remark:e}),message:!0})},G=t=>{X.value=t,e({isAsync:!0,title:"反向代理设置【".concat(t.proxy_path,"】"),area:[76,60],component:()=>a((()=>import("./setting2.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{row:t}})},J=async t=>{if("/"===t.proxy_path)return void W.error("根目录不能删除");await r({title:"删除反向代理【".concat(t.proxy_path,"】"),width:"35rem",icon:"warning-filled",content:"您真的要删除反向代理【".concat(t.proxy_path,"】吗?")});(await s({loading:"正在删除,请稍后...",request:n({site_name:M.value.name,proxy_path:t.proxy_path}),message:!0})).status&&(F.value=!0)},Y=[{content:"目标:可以填写你需要代理的站点,目标如果选URL地址则必须为可正常访问的URL,如果选UNIX则必须是套接字文件"},{content:"http地址示例:http://127.0.0.1:15700"},{content:"unix地址示例:/tmp/panel.sock"},{content:()=>T("span",null,[z("发送域名:将域名添加到请求头传递到后端服务器,默认为目标URL域名,若设置不当可能导致代理无法正常访问,例如:"),T("br",null,null),z("http://192.168.100.20:19888,则发送域名保持$http_host即可"),T("br",null,null),z("http://www.bt.cn,则发送域名应当改为www.bt.cn"),T("br",null,null),z("上面例子仅为常见情况,请以实际为准")])}],tt=[{label:"URL地址",value:"http"},{label:"UNIX地址",value:"unix"}],et=A({targetType:"http",sitename:"",cachetime:1,proxysite:"http://",todomain:"$http_host",path:"",ps:"",websocket:!1}),at=E(!1),st=E(!1),ot=E(!1),rt=E(),nt=A({proxyname:[{required:!0,message:"请输入代理名称",trigger:"blur"},{validator:(t,e,a)=>{e.length<3?a(new Error("代理名称必须大于3个字符串")):e.match(/^[a-zA-Z0-9_.-]+$/g)?a():a(new Error("代理名称不能包含特殊字符"))}}],proxysite:[{required:!0,message:"请输入目标地址",trigger:"blur"},{validator:(t,e,a)=>{if(!e)return void a(new Error("http"===et.targetType?"目标地址不能为空":"请选择sock文件"));if("unix"===et.targetType)return void a();let s=e.replace(/^http[s]?:\/\//,"");s=s.replace(/(:|\?|\/|\\)(.*)$/,""),/^(\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])$/.test(s)?et.todomain="$http_host":et.todomain=s,a()}},{}],todomain:[{required:!0,message:"请输入发送域名",trigger:["blur","change"]}],path:[{required:!0,message:"请输入根目录",trigger:"blur"}]}),lt=async()=>{et.proxysite="http"===et.targetType?"http://":""},it=t=>{if("unix"===et.targetType)return void(et.todomain="$http_host");let e=t.replace(/^http[s]?:\/\//,"");e=e.replace(/(:|\?|\/|\\)(.*)$/,""),et.todomain=e},pt=()=>{V({type:"file",path:et.proxysite||"/www/dk_project/wwwroot",change:t=>{et.proxysite=t}})},ct=()=>{et.targetType="http",et.sitename="",et.cachetime=1,et.proxysite="http://",et.todomain="$http_host",et.path="",et.ps="",et.websocket=!1},ut=async t=>{const{path:e,proxysite:a,todomain:o,targetType:r,ps:n}=et;let i={site_name:M.value.name,proxy_path:e,proxy_pass:a,proxy_host:o,proxy_type:r,remark:n};await rt.value.validate();(await s({loading:ot,request:l(i),message:!0})).status&&(F.value=!0,t&&t())},_t=E("proxy"),mt=E({proxy_type:"",proxy_path:"",proxy_pass:"",proxy_host:"$http_host",ip_limit:{},basic_auth:{},proxy_cache:{},gzip:{},sub_filter:{},websocket:{},proxy_log:{},custom_config:[],proxy_conf:"",remark:"",template_proxy_conf:""}),yt=async()=>{try{const e=await t({site_name:M.value.name,proxy_path:X.value.proxy_path});if(!e.status)return void W.error(e.msg);mt.value=e.data.data}catch(e){i(e)}},dt=E(!1),ht=A({targetType:"http",sitename:"",proxysite:"",todomain:"$http_host",path:"",ps:"",websocket:!1,proxy_connect_timeout:30,proxy_send_timeout:30,proxy_read_timeout:30}),gt=L((()=>({proxysite:[{required:!0,message:"http"!==ht.targetType?"请选择sock文件":"请输入目标url",trigger:"blur",validator:(t,e,a)=>{e?a():a(new Error("http"!==ht.targetType?"请选择sock文件":"请输入目标url"))}}],todomain:[{required:!0,message:"请输入发送域名",trigger:["blur","change"]}],proxy_connect_timeout:[{required:!0,message:"请输入连接超时时间",trigger:["blur","change"],validator:(t,e,a)=>{e?isNaN(Number(e))?a(new Error("请输入数字")):a():a(new Error("连接超时时间不能为空"))}}],proxy_send_timeout:[{required:!0,message:"请输入后端请求超时时间",trigger:["blur","change"],validator:(t,e,a)=>{e?isNaN(Number(e))?a(new Error("请输入数字")):a():a(new Error("后端请求超时时间不能为空"))}}],proxy_read_timeout:[{required:!0,message:"请输入代理响应超时时间",trigger:["blur","change"],validator:(t,e,a)=>{e?isNaN(Number(e))?a(new Error("请输入数字")):a():a(new Error("代理响应超时时间不能为空"))}}]}))),xt=t=>{const{proxy_type:e,proxy_pass:a,proxy_host:s,proxy_path:o,remark:r,global_websocket:n,websocket:l,timeout:i}=t;ht.targetType=e,ht.proxysite=a,ht.todomain=s,ht.path=o,ht.ps=r,dt.value=n,ht.websocket=null==l?void 0:l.websocket_status,ht.proxy_connect_timeout=null==i?void 0:i.proxy_connect_timeout,ht.proxy_send_timeout=null==i?void 0:i.proxy_send_timeout,ht.proxy_read_timeout=null==i?void 0:i.proxy_read_timeout},wt=()=>{V({type:"file",path:ht.proxysite||"/www",change:t=>{ht.proxysite=t}})},vt=t=>{if("unix"===ht.targetType)return void(ht.todomain="$http_host");let e=t.replace(/^http[s]?:\/\//,"");e=e.replace(/(:|\?|\/|\\)(.*)$/,""),ht.todomain=e},bt=async()=>{const{path:t,proxysite:e,todomain:a,targetType:o,ps:r,websocket:n,proxy_connect_timeout:l,proxy_send_timeout:i,proxy_read_timeout:c}=ht,u={site_name:M.value.name,proxy_path:t,proxy_pass:e,proxy_host:a,proxy_type:o,remark:r,websocket:n?1:0,proxy_connect_timeout:l,proxy_send_timeout:i,proxy_read_timeout:c};await rt.value.validate(),await s({loading:ot,request:p(u),message:!0})},kt='一行一条配置,请以;结尾,例如:\nproxy_set_header Cookie "cookie_name=cookie_value";\nallow 192.168.1.0/24;\naccess_log /www/wwwlogs/xxx.log;',ft=A({config:""}),jt=[{content:"注意:一行一条配置,请以;结尾"},{content:()=>T(N,null,[z("案例:"),T("br",null,null),z("重定向请求:return 301 /new-page;"),T("br",null,null),z("重写URL:rewrite ^/blog/(.*)$ /$1 break;"),T("br",null,null),z("文件上传限制:client_max_body_size 10M;"),T("br",null,null),z("处理特定http方法:"),T("br",null,null),z("limit_except POST "),"{",z(" "),T("br",null,null),z(" allow 192.168.1.0/24;"),T("br",null,null),z(" deny all;"),T("br",null,null),"}",T("br",null,null),z("限制请求速率:limit_rate 100k;"),T("br",null,null)])},{content:"保存配置前请核对配置是否正确,错误的配置可能会导致反向代理无法正常访问"}],qt=async t=>{try{let t={site_name:M.value.name,proxy_path:mt.value.proxy_path,custom_conf:ft.config};const e=await c(t);W.request(e)}catch(e){}},Et=()=>{ft.config=mt.value.custom_conf||""},Tt=A({subfilter:[]}),zt=[{content:"规则解释如下"},{content:"g:替换所有匹配到的关键字"},{content:"i:不区分大小写"},{content:"o:只替换匹配到的第一个"},{content:"r:使用正则表达式"}],At=async t=>{await s({loading:"正在删除,请稍后...",request:x({site_name:M.value.name,proxy_path:mt.value.proxy_path,oldstr:t.oldstr,newstr:t.newstr}),message:!0}),yt()},Lt=t=>{const e=[t.oldstr,t.newstr],a=t.sub_type.replace(/g/g,""),s=a.includes("i")?"不区分大小写":"",o=a.includes("o")?"只替换第一个":"",r=a.includes("r")?"使用正则表达式":"";switch(a.length){case 0:return"效果:将全部'".concat(e[0],"'替换为'").concat(e[1],"''");case 1:return"效果:将".concat(o?"":"全部","'").concat(e[0],"'替换为'").concat(e[1],"',匹配时").concat(s||o||r);case 2:return"效果:将".concat(o?"":"全部","'").concat(e[0],"'替换为'").concat(e[1],"',匹配时").concat(s||o||r,"并且").concat(r||o||s);case 3:return"效果:将'".concat(e[0],"'替换为'").concat(e[1],"',匹配时").concat(s,"、").concat(o,"并且").concat(r)}},Nt=t=>{try{Tt.subfilter=t.sub_filter_str}catch(e){}},$t=E([{label:"原关键词",prop:"oldstr"},{label:"替换词",prop:"newstr"},{label:"规则",prop:"mode",width:50,render:t=>T($,{class:"item",effect:"dark","open-delay":500,content:Lt(t),placement:"top-start"},{default:()=>[T("div",{class:"flex items-center"},["".concat(t.sub_type)])]})},U([{title:"删除",onClick:t=>{At(t)}}])]),It=()=>{Object.assign(Pt,{oldstr:"",newstr:""}),Rt.value=[],Ot.value="默认效果:将全部'http://www.bt.cn'替换为'https://www.bt.cn'",e({isAsync:!0,title:"添加内容替换【".concat(mt.value.proxy_path,"】"),area:60,btn:"确认",component:()=>a((()=>import("./setting-replace-add.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{proxy_path:mt.value.proxy_path,subs_filter:mt.value.subs_filter}})},Pt=A({oldstr:"",newstr:""}),Ct={oldstr:[u({message:"请输入原关键词"})]},Rt=E([]),Ot=E("默认效果:将全部'http://www.bt.cn'替换为'https://www.bt.cn'"),Ut=E(),Dt=t=>{Bt(Rt.value)},Bt=t=>{const e=t.includes("i")?"不区分大小写":"",a=t.includes("o")?"只替换第一个":"",s=t.includes("r")?"使用正则表达式":"";switch(t.length){case 0:Ot.value="默认效果:将全部".concat(Pt.oldstr,"替换为").concat(Pt.newstr);break;case 1:Ot.value="效果:将".concat(a?"":"全部").concat(Pt.oldstr,"替换为").concat(Pt.newstr,",匹配时").concat(e||a||s);break;case 2:Ot.value="效果:将".concat(a?"":"全部").concat(Pt.oldstr,"替换为").concat(Pt.newstr,",匹配时").concat(e||a||s,"并且").concat(s||a||e);break;case 3:Ot.value="效果:将".concat(Pt.oldstr,"替换为").concat(Pt.newstr,",匹配时").concat(e,"、").concat(a,"并且").concat(s)}},Vt=async t=>{await Ut.value.validate();const e={site_name:M.value.name,oldstr:Pt.oldstr,newstr:Pt.newstr,proxy_path:mt.value.proxy_path,sub_type:Rt.value.length?Rt.value.join(""):"g"};(await s({loading:ot,request:_(e),message:!0})).status&&(yt(),t&&t())},St=E(),Wt=A({status:!1,time:"",unit:"m"}),Mt=[{label:"分钟",value:"m"},{label:"小时",value:"h"},{label:"天",value:"d"}],Xt=[{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"}],Ft=t=>{Ht()},Ht=async()=>{const t={site_name:M.value.name,proxy_path:mt.value.proxy_path,cache_status:Wt.status?1:0,expires:"".concat(Wt.time).concat(Wt.unit)};await St.value.validate(),await s({loading:ot,request:m(t),message:!0})},Kt=A({status:!1}),Qt=async t=>{const e={site_name:M.value.name,proxy_path:mt.value.proxy_path,status:t?1:0};await s({loading:"正在保存,请稍后...",request:y(e),message:!0})},Zt=[{content:"启用缓冲(默认):Nginx 会将后端服务器(被代理的服务器)的响应数据先存储在自己的缓冲区中"},{content:"启用缓冲(默认):提高性能和稳定性,优化资源利用,但也会造成延迟问题,内存占用高"},{content:"关闭缓冲:数据访问实时性增强,降低内存占用风险,但也会对后端服务器(被代理的服务器)压力增大,性能也有一定影响"},{content:"什么业务可以关闭缓冲:例如AI类型的,比如ThinkChat等"}],Gt=E(),Jt=A({status:!1,type:"",level:1,minLength:"",unit:"m"}),Yt=[{label:"k",value:"k"},{label:"m",value:"m"}],te=[{content:"用于对 HTTP 响应的内容进行压缩,以减少数据传输量,提高网站性能和加载速度"},{content:"压缩级别1-9,例如:1为压缩速度最快,但压缩率较低;9为压缩速度最慢,但压缩率最高,建议默认"},{content:"如果开启gzip后影响网站正常访问,请关闭此功能 和请求参数组成"}],ee={type:[{required:!0,message:"请输入压缩类型",trigger:["blur","change"]}],minLength:[{required:!0,message:"请输入正确的压缩最小长度",trigger:"blur",validator:(t,e,a)=>{e?isNaN(Number(e))?a(new Error("请输入数字")):Number(e)<1?a(new Error("请输入正确数字")):a():a(new Error("压缩最小长度不能为空"))}},{}]},ae=t=>{Jt.status=t.gzip_status,Jt.type=t.gzip_types,Jt.level=t.gzip_comp_level;let e="",a="m";t.gzip_min_length&&t.gzip_min_length.length>1&&(e=t.gzip_min_length.slice(0,-1),a=t.gzip_min_length.slice(-1)),Jt.minLength=e,Jt.unit=a},se=t=>{oe()},oe=async()=>{const t={site_name:M.value.name,proxy_path:mt.value.proxy_path,gzip_status:Jt.status?1:0,gzip_min_length:"".concat(Jt.minLength).concat(Jt.unit),gzip_comp_level:Jt.level,gzip_types:Jt.type};await Gt.value.validate(),await s({loading:ot,request:d(t),message:!0})},re=A({loading:!1,type:"black",white:[],black:[]}),ne=t=>{re.white=t.ip_white.map((t=>({ip:t,type:"white"}))),re.black=t.ip_black.map((t=>({ip:t,type:"black"})))},le=async t=>{const e=!!Array.isArray(t);await r({title:"".concat(e?"批量删除":"删除").concat("white"===re.type?"白":"黑","名单"),content:"".concat(e?"批量删除选中的ip,是否继续操作?":"删除".concat("white"===re.type?"白":"黑","名单【").concat(t.ip,"】,是否继续操作?"))});let a={site_name:M.value.name,proxy_path:mt.value.proxy_path};e?(a.ips=t.map((t=>t.ip)).join("\n"),a.ip_type=re.type):(a.ip=t.ip,a.ip_type=t.type);const o=e?w:v;(await s({loading:"正在删除,请稍后...",request:o(a),message:!0})).status&&yt()},ie=E([D(),{label:"IP",prop:"ip",minWidth:120},U([{title:"删除",onClick:t=>{le(t)}}])]),pe=[{label:"删除IP",value:"delete",event:async(t,e,a,s)=>{le(a.value)}}],ce=()=>{re.type="ipBlackList"===_t.value?"black":"white",_e.value.types=re.type,_e.value.address="",ne(mt.value.ip_limit)},ue=()=>{e({isAsync:!0,title:"添加IP".concat("ipBlackList"===_t.value?"黑":"白","名单【").concat(mt.value.proxy_path,"】"),area:40,btn:"确认",component:()=>a((()=>import("./setting-ip-add.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{name:M.value.name,proxy_path:mt.value.proxy_path,listType:re.type,refreshEvent:()=>{_e.value.address="",yt()}}})},_e=E({types:re.type,address:""}),me=E(),ye=[{content:"一行一条配置,多个IP请换行"}],de={address:[{validator:(t,e,a)=>{e.length>0?a():a(new Error("请输入IP地址"))},trigger:["blur","change"]}]},he=async t=>{const{types:e,address:a}=_e.value,o={site_name:M.value.name,proxy_path:mt.value.proxy_path,ip_type:e,ips:a};await me.value.validate();(await s({loading:ot,request:h(o),message:!0})).status&&(_e.value.address="",yt(),t())},ge=I({__name:"index",setup(t,{expose:e}){const{BtOperation:a}=b({options:[{label:"添加反向代理",type:"button",active:!0,onClick:Q}]}),{BtTable:s,refresh:o}=k({request:K,columns:[{label:"代理目录",prop:"proxy_path",minWidth:120},{label:"目标",prop:"proxy_pass",minWidth:200},B({request:Z,prop:"remark"}),U([{onClick:G,title:"设置"},{onClick:J,title:"删除"}])],extension:[f(F)]});return e({init:o}),(t,e)=>{const o=q,r=j;return P(),C("div",null,[T(o,{class:"h-[59rem]"},{"header-left":R((()=>[T(O(a))])),content:R((()=>[T(O(s),{"max-height":560})])),_:1}),T(r,{class:"mt-[2rem] ml-[1.6rem]",options:O(H)},null,8,["options"])])}}}),xe=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"}));export{Qt as $,It as A,Tt as B,$t as C,zt as D,Nt as E,Wt as F,Ft as G,Mt as H,Ht as I,St as J,Xt as K,ae as L,Jt as M,se as N,Yt as O,oe as P,Gt as Q,ee as R,te as S,_t as T,ue as U,ce as V,re as W,ie as X,pe as Y,ne as Z,Kt as _,pt as a,Zt as a0,yt as a1,Vt as a2,Pt as a3,Dt as a4,Rt as a5,Bt as a6,Ot as a7,Ut as a8,Ct as a9,he as aa,_e as ab,ye as ac,me as ad,de as ae,xe as af,rt as b,nt as c,ot as d,Y as e,st as f,xt as g,it as h,ct as i,mt as j,ht as k,vt as l,wt as m,dt as n,ut as o,at as p,bt as q,gt as r,lt as s,tt as t,et as u,Et as v,ft as w,kt as x,qt as y,jt as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel