import{u as l,l as e,dj as a,t,M as s,x as n}from"./utils-lib.js?v=20260328163632";import{B as r}from"./index85.js?v=20260328163632";import{u as o}from"./store4.js?v=20260328163632";import{bH as u,bI as i}from"./site.js?v=20260328163632";import{n as p,p as c}from"./useMethod4.js?v=20260328163632";import{k as m,a9 as d,c as v,r as h,O as b,j as y,o as w,V as f,_ as g,Y as x}from"./base-lib.js?v=20260328163632";import{g as j,b as k}from"./naive-ui.js?v=20260328163632";const _=m({__name:"index",setup(m,{expose:_}){const{siteInfo:I,isRefreshList:C}=o(),{panel:O,isWin:A}=l(),{sitePath:H}=d(O.value),V=v((()=>((H.value||"C:/wwwroot")+"/").replace(/\/\//g,"/"))),J=v((()=>!!I.value));h(0),h("shell"),h(!1);const M=h({formAttrs:{labelWidth:"120px"},formItems:[]}),P=h({label:e("项目名称"),ruleKey:"name",rules:p.name,children:[{type:"input",key:"name",attrs:{placeholder:e("请选择项目路径，自动获取名称"),clearable:!0,class:"!w-460px",disabled:J.value,onInput:l=>{U.value.ps=l,U.value.static_path=V.value+U.value.name}}}]}),K=h({label:e("项目路径"),ruleKey:"path",rules:p.path,children:[{type:"custom",key:"path",render:()=>b(r,{modelValue:U.value.path,"onUpdate:modelValue":l=>U.value.path=l,onIconClick:()=>{a({type:"dir",path:U.value.path,callback:l=>{let e=l.substring(l.lastIndexOf("/")+1).split(".")[0];U.value.ps=e,J.value||(U.value.name=e),U.value.path=l}})},placeholder:e("请选择项目路径"),width:"420px",icon:"el-folder-opened"},null)}]}),q=h({label:e("启动命令"),ruleKey:"command",rules:p.command,children:[{type:"input",key:"command",attrs:{type:"textarea",rows:2,placeholder:e("请输入启动命令"),class:"!w-460px",onInput:l=>{var e;if(l){const a=(null==(e=null==l?void 0:l.match(/([0-9]*)$/))?void 0:e[0])||"";a&&(U.value.port=a)}}}}]}),E=h({label:b("div",{class:"flex items-center"},[e("环境变量"),b(j,{placement:"top-start",width:400,class:"popper-dark",trigger:"hover"},{default:()=>b("div",null,[b("span",{class:"text-[#fff]"},[e("环境变量，1行1个，例如： JAVA_HOME=/usr/local/btjdk/jdk8"),b("br",null,null),b("br",null,null),e("项目启动方式"),b("br",null,null),e("1、完整命令启动：C:/python/python.exe d:/wwwroot/run.py"),b("br",null,null),e("2、配置环境目录和运行目录，如"),b("br",null,null),y("    DIR=d:/wwwroot"),b("br",null,null),y("    PATH=C:/python"),b("br",null,null),b("br",null,null),y("    "),e("启动命令: python run.py")])]),trigger:()=>b("i",{class:"inline-block svgtofont-el-question-filled text-warning ml-[4px] cursor-pointer"},null)})]),children:[{type:"input",key:"env_list",attrs:{type:"textarea",rows:3,placeholder:e("环境变量，1行1个，例如： JAVA_HOME=/usr/local/btjdk/jdk8"),clearable:!0,class:"!w-460px"}}]}),N=h({label:e("绑定域名"),children:[{type:"custom",render:()=>b(j,{placement:"top-start",class:"popper-primary",width:400,trigger:"focus"},{default:()=>b("div",{class:"bg-primary text-white"},[e("如需绑定外网，请输入需要绑定的域名，该选项可为空"),b("br",null,null),e("如需填写多个域名，请换行填写，每行一个域名，默认为80端口"),b("br",null,null),e("IP地址格式：192.168.1.199"),b("br",null,null),e("泛解析添加方法：先添加一个域名 domain.com，后换行添加*.domain.com"),b("br",null,null),e("如另加端口格式为 www.domain.com:88")]),trigger:()=>b(k,{value:U.value.domains,"onUpdate:value":l=>U.value.domains=l,placeholder:e("如需绑定外网，请输入需要绑定的域名，该选项可为空")+"\n"+e("如需填写多个域名，请换行填写，每行一个域名，默认为80端口")+"\n"+e("IP地址格式：192.168.1.199")+"\n"+e("泛解析添加方法 *.domain.com")+"\n"+e("如另加端口格式为 www.domain.com:88"),type:"textarea",rows:4,class:"!w-460px"},null)})}]}),R=h({label:" ",children:[{type:"button",key:"save",attrs:{buttonText:e("保存项目配置"),type:"primary",onClick:()=>B()}}]}),S=v((()=>(M.value.formItems=[K.value,P.value,q.value,E.value,c.value,...J.value?[R.value]:[N.value]],M.value))),[T,U,W]=t(S),B=async()=>{try{await W.value.validate();const{name:l,path:a,ps:t,command:r,domains:o,env_list:p}=U.value,c={command:r,path:a,ps:t,name:l,...p?{env_list:JSON.stringify(p.split("\n"))}:{},...o?{domains:JSON.stringify(o.split("\n"))}:{}},m=s.load(e("正在提交，请稍后..."));return(await n({request:J.value?u({id:I.value.id,...c}):i(c),success:async l=>{m&&m.close(),s.msg({customClass:"bt-message-error-html",isHtml:!0,message:l.msg,type:l.status?"success":"error",duration:l.status?3e3:0,showClose:!l.status}),C.value=!0}})).status}catch(l){}};return w((async()=>{const{path:l}=U.value;if(Object.assign(U.value,{path:l||V.value}),J.value){const{name:l,path:e,ps:a,project_config:{command:t,port:s,env_list:n}}=I.value;Object.assign(U.value,{name:l,path:e,ps:a,command:t,port:s}),(null==n?void 0:n.length)&&(U.value.env_list=n.join("\n"))}})),_({onConfirm:B}),(l,e)=>(f(),g(x(T),{class:"p-20px"}))}});export{_};
