File: /www/server/panel/BTPanel/static/js/useController29.js
import{k as p,M as m,c as S,e as E,_ as f,df as D,w as g}from"./utils-lib.js?v=1777008528";import{aJ as P,r as x,aI as C,e as d,x as y,F as T,n as b,H as A}from"./base-lib.js?v=1777008528";import{o as B,w as N}from"./index3.js?v=1777008528";import{u as F,S as R}from"./useStore2.js?v=1777008528";import{delProxyProject as k,batchDelNginx as I,addProxyProject as L,proxyTcpAction as h,getProxyConfigFile as $,setProxySiteStop as V}from"./site.js?v=1777008528";import{l as O,o as U}from"./useController13.js?v=1777008528";const v=P("SITE-PROXY-STORE",()=>{const{isRefreshList:t}=F();return{proxyType:x("http"),deleteProxySiteEvent:async(n,a)=>{try{let l={remove_path:a?1:0,id:n.id,site_name:n.name};const r=await p({loading:"正在删除反向代理项目,请稍候...",request:k(l),message:!0});return t.value=!0,{status:r.status,msg:r.msg}}catch(l){return{status:!1,msg:"删除项目失败"}}},multDeleteProxySiteEvent:async n=>{try{const a=await p({loading:"正在删除反向代理项目,请稍候...",request:I(n),message:!1});return t.value=!0,{status:a.status,msg:a.msg,data:a.data.data.map(l=>({...l,name:l.site_name}))}}catch(a){return{status:!1,msg:"删除项目失败",data:[]}}},addProxySiteEvent:async n=>{try{return{...await L(n)}}catch(a){}},addProxyTcpEvent:async n=>{try{return{...await h(n)}}catch(a){}},getConfigEvent:async n=>{try{const{data:a}=await $(n);return a.status||m.error(a.msg),{data:a.data,status:a.status}}catch(a){return{msg:"获取配置失败",status:!1}}}}},{persist:[{storage:localStorage,paths:["proxyType"]}]}),{plugin:q}=S(),{isRefreshList:w}=F(),{setSiteInfo:M}=R(),{deleteProxySiteEvent:H,multDeleteProxySiteEvent:j,addProxySiteEvent:X,addProxyTcpEvent:J,getConfigEvent:et}=v(),{proxyType:Y}=C(v()),at=()=>{E({title:"添加反向代理项目",area:62,component:()=>f(()=>import("./index258.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),showFooter:!0})},st=(t,e="")=>{M(t,e),E({title:"反向代理项目管理["+(t.rname||t.name)+"] -- 添加时间["+t.addtime+"]",area:[84,70],component:()=>f(()=>import("./index259.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},rt=async(t,e)=>{var o,u;e==="monitor"&&D("total_website",t.name);const s=((u=(o=q.value)==null?void 0:o.web)==null?void 0:u.type)==="nginx"?"btwaf":"btwaf_httpd";await B({name:e==="total"?"total":e==="monitor"?"monitor":s,callback:c=>{if(e!=="monitor"&&c&&!["total","monitor"].includes(e)&&s==="btwaf"){const n=setInterval(()=>{var l;const a=c.document.getElementsByClassName("layui-layer-page")[0];if(c.site_waf_config&&a){clearInterval(n),a&&(a.style.display="none"),c.site_waf_config(t.name);const r=c.document.getElementsByClassName("layui-layer-page")[1];r&&((l=r.querySelector(".layui-layer-close"))==null||l.addEventListener("click",()=>{var _;(_=a.querySelector(".layui-layer-close"))==null||_.click()}))}},50)}}})},ot=async t=>{await g({title:"".concat("删除反向代理项目【".concat(t.rname||t.name,"】")),content:"".concat("风险操作,此操作不可逆,删除【".concat(t.rname||t.name,"】项目后您将无法管理该项目,是否继续操作?")),type:"check",check:{content:"同时删除网站根目录",onConfirm:async e=>await H(t,e)}})},nt=async(t,e)=>{await g({title:"批量删除反向代理项目",content:"批量删除选中的项目后,项目将无法恢复,是否继续操作?",type:"check",check:{content:"同时删除网站根目录",onConfirm:async i=>{let s={remove_path:i?1:0,site_list:JSON.stringify(t.map(u=>({id:u.id,site_name:u.name})))};const{data:o}=await j(s);U({resultData:o,resultTitle:"批量删除反向代理项目"}),e()}}})},ut=[{content:"目标:可以填写你需要代理的站点,目标如果选URL地址则必须为可正常访问的URL,如果选UNIX则必须是套接字文件"},{content:"http地址示例:http://127.0.0.1:15700"},{content:"unix地址示例:/tmp/panel.sock"},{content:()=>d(T,null,[y("发送域名:将域名添加到请求头传递到后端服务器,默认为目标URL域名,若设置不当可能导致代理无法正常访问,例如:"),d("br",null,null),y("http://192.168.100.20:19888,则发送域名保持$http_host即可"),d("br",null,null),y("http://www.bt.cn,则发送域名应当改为www.bt.cn"),d("br",null,null),y("上面例子仅为常见情况,请以实际为准")])}],it=[{value:"url",label:"URL地址"},{value:"unix",label:"unix地址"}],G=x(!1),lt=async(t,e,i)=>{let s;try{await e();const{ps:o,listen_port:u,protocol:c,proxy_pass:n,isEdit:a}=t.value,l={ps:o,listen_port:u,protocol:c,proxy_pass:n,handle:a?"update":"create"};s=m.load("正在"+(a?"编辑":"添加")+"项目,请稍后...");const r=await J(l);return m.msg({dangerouslyUseHTMLString:!0,message:r.msg,type:r.status?"success":"error",duration:r.status?2e3:0,showClose:!r.status,customClass:"!max-w-[66rem] bt-message-error-html"}),r.status&&(G.value=!0),r.status}catch(o){return!1}finally{s==null||s.close()}},ct=async t=>{try{const e=await p({request:h({handle:"list"}),data:{data:Array}});return Array.isArray(e.data)?{data:e.data.map(i=>{const[s,o]=i.listen_port.split(" ");return{...i,listen_port:s,protocol:o||"tcp"}}).filter(i=>t.search?i.listen_port.toString().includes(t.search):!0).sort((i,s)=>{try{const o=parseInt(i.id),u=parseInt(s.id);return isNaN(o)&&isNaN(u)?0:isNaN(o)?1:isNaN(u)?-1:u-o}catch(o){return 0}}),total:e.data.length}:{data:[],total:0}}catch(e){return{data:[],total:0}}},pt=async(t,e)=>{await g({title:"删除代理【".concat(t.listen_port,"】"),width:"35rem",icon:"warning-filled",content:"您真的要删除代理【".concat(t.listen_port,"】吗?")}),(await p({loading:"正在删除,请稍后...",request:h({handle:"delete",protocol:t.protocol,listen_port:t.listen_port,proxy_pass:t.proxy_pass}),message:!0})).status&&e()},mt=t=>{E({isAsync:!0,title:"".concat(t.protocol.toUpperCase(),"代理设置【").concat(t.listen_port,"】"),area:[76,60],component:()=>f(()=>import("./setting2.js?v=1777008528").then(e=>e.s),__vite__mapDeps([]),import.meta.url),compData:{row:t}})},dt=async(t,e,i)=>{let s;try{await e();const{remark:o,targetType:u,proxysite:c,domains:n,todomain:a}=t.value,l={remark:o,proxy_type:u==="url"?"http":"unix",proxy_pass:c,domains:n,proxy_host:a};l.domains.includes("[")&&await O(),s=m.load("正在添加项目,请稍后...");const r=await X(l);return m.msg({dangerouslyUseHTMLString:!0,message:r.msg,type:r.status?"success":"error",duration:r.status?2e3:0,showClose:!r.status,customClass:"!max-w-[66rem] bt-message-error-html"}),r.status&&(Y.value="http",b(()=>{w.value=!0})),r.status}catch(o){return!1}finally{s==null||s.close()}},yt=t=>{N({type:"file",path:t.proxysite,change:e=>{t.proxysite=e}})},gt=A({title:"标题",body:"网页内",keywords:"关键词",descriptions:"描述",title_update:"标题更新",keywords_update:"关键词更新",description_update:"描述更新",tail_hash_update:"尾部script代码块更新",title_hash_update:"头部head代码块更新"}),Et=async t=>{try{const e=Number(t.status);await g({title:"温馨提示",content:e?"即将停用反代项目【".concat(t.rname||t.name,"】,是否继续操作?"):"即将启动反代项目【".concat(t.rname||t.name,"】,是否继续操作?"),icon:"warning-filled"}),await p({loading:"正在".concat(e?"停用":"启动","反代项目,请稍后..."),request:V({site_name:t.name,status:e?0:1}),message:!0,success:()=>{w.value=!0}})}catch(e){}};export{v as S,st as a,at as b,Et as c,ot as d,mt as e,pt as f,ct as g,ut as h,dt as i,it as j,yt as k,lt as l,nt as m,rt as o,G as r,gt as t};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = []
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}