import{u as t,l as e,bH as s,x as a,M as l,A as r,a7 as o,t as u,v as n}from"./utils-lib.js?v=20260328163632";import{O as i,F as p,k as m,r as c,c as d,o as h,V as v,W as y,Y as g}from"./base-lib.js?v=20260328163632";import{u as b}from"./store4.js?v=20260328163632";import{bE as w,bF as _}from"./site.js?v=20260328163632";import{b as f,g as x}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";const{isAaPanel:k,publicUrl:U}=t(),j=[{value:"url",label:"URL"+e("地址")}],L=[{content:e("目标：可以填写你需要代理的站点，目标如果选URL地址则必须为可正常访问的URL")},{content:e("http地址示例：http://127.0.0.1:15700")},{content:i(p,null,[e("发送域名：将域名添加到请求头传递到后端服务器，默认为目标URL域名，若设置不当可能导致代理无法正常访问，例如："),i("br",null,null),e("http://192.168.100.20:19888，则发送域名保持$http_host即可"),i("br",null,null),e("{0}，则发送域名应当改为",[U.value])+k.value,i("br",null,null),e("上面例子仅为常见情况，请以实际为准")])}],R={class:"p-20px max-w-800px"},D=m({__name:"index",setup(t,{expose:p}){const{isRefreshList:m}=b(),k={labelStyle:"min-width: 120px"},U=c({formAttrs:{labelWidth:"auto"},formItems:[]});c({label:e("网站别名"),attrs:k,children:[{type:"input",key:"title",attrs:{class:"!w-440px",placeholder:e("请输入网站别名")}}]});const D=c({label:e("域名"),attrs:k,ruleKey:"domains",rules:[s()],children:[{type:"custom",render:()=>i(x,{placement:"top-start",class:"popper-primary",width:440,trigger:"focus"},{default:()=>i("div",{class:"bg-primary text-white"},[e("如需填写多个域名，请换行填写，每行一个域名，默认为80端口"),i("br",null,null),e("IP地址格式：192.168.1.199"),i("br",null,null),e("泛解析添加方法：先添加一个域名 domain.com，后换行添加*.domain.com"),i("br",null,null),e("如另加端口格式为 www.domain.com:88")]),trigger:()=>i(f,{value:A.value.domains,"onUpdate:value":t=>A.value.domains=t,placeholder:e("如需填写多个域名，请换行填写，每行一个域名，默认为80端口")+"\n"+e("IP地址格式：192.168.1.199")+"\n"+e("泛解析添加方法 *.domain.com")+"\n"+e("如另加端口格式为 www.domain.com:88"),type:"textarea",rows:3,class:"!w-440px relative domain-input",onInput:t=>{A.value.ps=t.split("\n")[0]}},null)})}]}),T=c({label:e("目标"),attrs:k,ruleKey:"to_url",rules:[{validator:(t,s)=>{if(!s)return new Error("url"===A.value.targetType?e("目标地址不能为空"):e("请选择sock文件"));if("unix"===A.value.targetType)return!0;const a=s.trim();if(/^https?:\/\/$/.test(a))return new Error(e("请输入目标URL域名"));if(!/^https?:\/\/.+/.test(a))return new Error(e("目标URL格式不正确，应以http://或https://开头"));let l=s.replace(/^http[s]?:\/\//,"");return l=l.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(l)?A.value.toDomain="$http_host":A.value.toDomain=l,!0},trigger:["blur","input"]}],children:[{type:"select",key:"targetType",style:"min-width: 120px",attrs:{class:"!w-110px",placeholder:e("请选择"),consistentMenuWidth:!1,options:j}},{type:"input",key:"to_url",style:"min-width: 242px",attrs:{class:"!w-232px",placeholder:e("请输入目标地址")}},{type:"button",key:"check",attrs:{buttonText:e("验证地址"),onClick:()=>{a({request:w({to_url:A.value.to_url}),message:!1,success:t=>{t.status?r({title:e("测试URL结果")+"[".concat(A.value.to_url,"]"),area:600,component:()=>o((()=>import("./test-url-result.js?v=20260328163632")),[],import.meta.url),compData:{result:t.data}}):l.msg({customClass:"bt-message-error-html",isHtml:!0,message:t.msg,type:"error",duration:0,showClose:!0})}})}}}]}),$=c({label:e("发送域名(host)"),attrs:k,ruleKey:"toDomain",rules:[{required:!0,message:e("请输入发送域名"),trigger:["blur","input"]}],children:[{type:"custom",key:"toDomain",render:()=>i(x,{placement:"top-start",class:"popper-dark",width:440,trigger:"focus"},{trigger:()=>i(f,{value:A.value.toDomain,"onUpdate:value":t=>A.value.toDomain=t,placeholder:e("请输入发送域名"),class:"!w-440px"},null),default:()=>i("div",null,[e("请求转发到后端服务器时的主机名，一般为$http_host")+e("，如果目标URL是域名，则需要改为域名")])})}]}),C=c({label:e("备注"),attrs:k,children:[{type:"input",key:"ps",attrs:{class:"!w-440px",placeholder:e("请输入备注，可为空")}}]}),E=d((()=>(U.value.formItems=[D.value,T.value,$.value,C.value],U.value))),[I,A,H]=u(E);return h((()=>{Object.assign(A.value,{targetType:"url",to_url:"http://",toDomain:"$http_host",ps:"",domains:""})})),p({onConfirm:async t=>{var s;try{await(null==(s=H.value)?void 0:s.validate());const{targetType:t,domains:r,...o}=A.value;let u={...o,type_id:0,domains:r?JSON.stringify(r.split("\n")):""};return(await a({loading:e("正在添加反向代理，请稍候..."),request:_(u),success:async t=>{l.msg({customClass:"bt-message-error-html",isHtml:!0,message:t.msg,type:t.status?"success":"error",duration:t.status?3e3:0,showClose:!t.status}),m.value=!0}})).status}catch(r){}}}),(t,e)=>(v(),y("div",R,[i(g(I)),i(g(n),{options:g(L)},null,8,["options"])]))}});export{D as default};
