import{getSystemUserList as t,advanceCheckPort as a,getProjectList as s,getSiteTypes as e,getProjectInfo as r,createProject as u,modifyProject as n,removeProject as o,getFileBody as c,saveFileBody as l,setProject as i,getPhpVersion as d}from"./site.js?v=1761009159";import{u as g,M as m,P as y,aA as v,az as p}from"./utils-lib.js?v=1761009159";import{j as h,s as j,r as f,g as _,b as w}from"./base-lib.js?v=1761009159";const b=h("SITE-STORE",()=>{const{mainWidth:h}=g(),j=f(""),b=f(!1),P=_(()=>{var t;const a=(null==(t=w())?void 0:t.name)||"php";return"otherModel"===a?"other":a.replace("site-","")}),S=f(!1),E=f(!1),T=f({addtime:"",edate:"0000-00-00",id:null,index:null,listen:[],listen_ok:!0,load_info:{},name:"",path:"",project_config:{},project_type:"",ps:"",rname:"",run:!1,ssl:{},status:"",stop:"",type_id:0}),q=f(""),L=f([]),x=f({enable:!1,exclude:[]}),C=f(!1),M=f(),A=_(()=>h.value>1530?320:h.value>1400?200:h.value>1200?180:140),H=async(t,a)=>{var s,e,r;if(t){"PHPMOD"===(null==(s=null==t?void 0:t.project_config)?void 0:s.type)&&(t.project_type="phpasync");let a=(null==(e=null==t?void 0:t.project_type)?void 0:e.toLowerCase())||"";a||(a=P.value),"node"===a&&(a="nodejs"),"nginx"===a&&(a="proxy"),T.value={...t,project_type:a},q.value=(null==(r=T.value)?void 0:r.project_type)||""}return j.value=(p(a)?a:"")||"",T.value};return{activeType:P,isRefreshList:S,isBindExtranet:E,siteInfo:T,siteType:q,rowData:M,settingTabActive:j,isJump:b,selectedList:L,searchWidth:A,jumpTabEvent:t=>{j.value=t,b.value=!0},resetTab:()=>{j.value="",b.value=!1},setSiteInfo:H,getRootUser:async a=>{try{const s=await t(a);return{data:s.data,status:s.status}}catch(s){return{msg:"获取用户列表失败",status:!1}}},getSiteList:async t=>{try{const a=await y({request:s(t,P.value),data:{data:Array,page:String}});return{data:a.data,total:v(a.page),other:{}}}catch(a){return{data:[],total:0,other:{}}}},getClassList:async()=>{try{let t=[];return await y({request:e(P.value),data:Array,success:a=>{t=[{label:"全部分类",value:"all"},...a.map(t=>({label:t.name,value:String(t.id)}))]}}),{data:t,status:!0}}catch(t){return{data:[],status:!1}}},getPhpVersionList:async()=>{try{const t=await y({request:d()});return{data:t.data,status:t.status}}catch(t){return{status:!1,msg:"获取PHP版本失败"}}},getProjectConfig:async t=>{var a,s;try{const e=await y({request:r(t,P.value)});return H(e.data),E.value=1===(null==(s=null==(a=e.data)?void 0:a.project_config)?void 0:s.bind_extranet)||!1,{data:e.data,status:e.status}}catch(e){return{msg:"获取失败",status:!1,data:{}}}},addGeneralProject:async t=>{const a=m.load("正在添加项目，请稍后...");try{const{data:a}=await u(t,P.value),s=a.msg||a.data||a.error_msg;return s?{status:a.status,msg:s}:{status:a.status,data:a}}catch(s){return{status:!1,msg:"添加项目失败"}}finally{a.close()}},editGeneralProject:async t=>{const a=m.load("正在编辑项目，请稍后...");try{const{data:a}=await n(t,P.value);if("string"==typeof a)return{status:!1,msg:a};const s=a.msg||a.data||a.error_msg;return s?{status:a.status,msg:s}:{status:a.status,data:a}}catch(s){return{status:!1,msg:"编辑项目失败"}}finally{a.close()}},getFileEvent:async t=>{try{const a=await c(t);return{data:a.data,status:a.status}}catch(a){return{status:!1,msg:"获取配置文件失败"}}},saveFileEvent:async t=>{try{const a=await y({loading:"正在保存内容，请稍候...",request:l(t),data:{status:Boolean,msg:String}});return m.msg({dangerouslyUseHTMLString:!0,message:a.msg,type:a.status?"success":"error",duration:a.status?2e3:0,showClose:!a.status}),{status:a.status,msg:a.msg}}catch(a){return{status:!1,msg:"保存文件失败"}}},checkPortUseEvent:async t=>{if(t&&"object"!=typeof t)try{const s=await a({port:t},"go");return s.status||m.request(s),{status:s.status,msg:s.msg}}catch(s){return{status:!1,msg:"检查端口失败"}}},delGeneralProjectEvent:async t=>{try{const{data:a}=await y({loading:"正在删除项目，请稍后...",request:o(t,P.value)});return{status:a.status,msg:a.msg||a.data||a.error_msg}}catch(a){return{status:!1,msg:"删除项目失败"}}},setProjectStatusEvent:async(t,a,s)=>{try{const{data:e}=await y({loading:"正在".concat("restart"!==a?"设置状态":"重启项目","，请稍后..."),request:i(t,s,a)});m.msg({customClass:"bt-message-error-html",dangerouslyUseHTMLString:!0,message:e.status?e.msg||e.data:e.error_msg||e.data||e.msg,type:e.status?"success":"error",duration:e.status?3e3:0,showClose:!e.status});const r=e.msg||e.data||e.error_msg;return{status:e.status,msg:r}}catch(e){return{status:!1,msg:"操作失败"}}},batchConfig:x,isSiteMult:C}}),P=()=>j(b());export{b as S,P as u};
