import{_ as a}from"./index105.js?v=1761009159";import{c as e,r as t,q as l,H as s,v as r,x as n,e as i,B as o,C as d,I as p,y as u,z as m,Q as c,F as b,b0 as _,N as v,A as f,G as w,bO as y,bN as h}from"./base-lib.js?v=1761009159";import{P as x,am as k,V as g,az as j,x as C,l as V,j as H,b as q,p as I,_ as N}from"./utils-lib.js?v=1761009159";import{_ as O}from"./index119.js?v=1761009159";import{u as z}from"./column.js?v=1761009159";import{getPM2Monit as A,getPM2Logs as S,setPM2Status as U}from"./site.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";const B={class:"p-2rem"},D={class:"p-2rem"},F={class:"p-2rem w-full relative"},G=["title"],J=N(e({__name:"index",setup(e){const N=q(),J=t([]),P=t(!1),Q=t(!1),E=t(""),K=t(!1),L=t({}),M=t({}),R=t(""),T=t(!1),W=async(a=!1)=>{const e=await x({loading:P,request:A(),data:{data:[Array,a=>a.map(a=>{var e;return a.id=null!=(e=a.id)?e:a.name+"(集群)",a})]}});J.value=e.data,a&&N.success("刷新成功")},X=async(a,e)=>{try{K.value=!0;let t={mode:a.mode,log_type:e};k(a.id)?t.id=a.id:t.name=a.name;const{data:l}=await S(t);E.value=l.data}catch(t){}finally{K.value=!1}},Y=async(a,e=!1)=>{let t="online"===a.status?"stop":"start",l=e?"重启":"stop"===t?"停止":"启动";await I({title:"修改集群状态",content:"即将".concat(l,"集群，是否继续？")});let s={mode:a.mode,status:e?"restart":t,name:a.name};k(a.id)?s.id=a.id:s.name=a.name;(await x({loading:"正在".concat(l,"集群，请稍后..."),request:U(s)})).status&&W()},Z=(a,e)=>{E.value="",Q.value=!0,L.value=a,R.value=e,X(a,e)},$=[{label:"ID",prop:"id",width:100},{label:"服务名称",prop:"name",width:110,render:a=>a.data?a.name:i("span",{class:"text-primary cursor-pointer",onClick:()=>(a=>{L.value=a,M.value=a.pm2_env,T.value=!0})(a)},[a.name])},{label:"pid",prop:"pid",render:a=>{var e;return null!=(e=a.pid)?e:"--"}},{label:"运行用户",prop:"user",width:75},{label:"重启次数",prop:"restart",width:75,render:a=>a.restart||"--"},{label:"创建时间",prop:"addtime",width:150,render:a=>g(a.uptime)},{label:"cpu使用率",prop:"cpu",render:a=>j(a.cpu)?a.cpu+"%":"--"},{label:"内存占用",prop:"memory",render:a=>void 0!==a.memory?C(a.memory):"--"},{label:"日志",prop:"log",width:120,render:a=>i("div",null,[i("span",{class:"bt-link cursor-pointer",onClick:()=>Z(a,"all")},[d("全部/")]),i("span",{class:"bt-link cursor-pointer",onClick:()=>Z(a,"err")},[d("错误/")]),i("span",{class:"bt-link cursor-pointer",onClick:()=>Z(a,"out")},[d("运行")])])},{label:"自动重载",width:75,prop:"auto_restart",render:a=>a.data?"--":a.auto_restart?"是":"否"},{label:"状态",prop:"status",render:a=>{let e="online"===a.status;return i("span",{class:"text-".concat(e?"primary":"danger")},[e?"运行中":"已停止"])}},z([{onClick:a=>Y(a),isHide:a=>!("online"===a.status),title:"停止",width:26},{onClick:a=>Y(a),isHide:a=>"online"===a.status,title:"启动",width:26},{onClick:a=>Y(a,!0),title:"重启",width:26}])];return l(()=>{W()}),(e,t)=>{const l=w,x=V,k=O,g=H,j=y,C=h,q=a,I=s("bt-loading");return r(),n("div",B,[i(q,null,{"header-left":o(()=>[i(l,{onClick:t[0]||(t[0]=a=>W(!0)),type:"default"},{default:o(()=>t[4]||(t[4]=[d("刷新数据",-1)])),_:1,__:[4]})]),content:o(()=>[p(i(x,{column:u($),data:u(J),"row-key":"id","max-height":500,"tree-props":{children:"data"}},null,8,["column","data"]),[[I,u(P)]])]),"footer-left":o(()=>t[5]||(t[5]=[m("ul",{class:"mt-8px leading-8 text-small list-disc ml-20px"},[m("li",null,"如果pm2项目无法加载监控信息，可修改node命令行版本号再试")],-1)])),popup:o(()=>[i(g,{title:"日志展示",modelValue:u(Q),"onUpdate:modelValue":t[2]||(t[2]=a=>c(Q)?Q.value=a:null),area:[60]},{default:o(()=>[m("div",D,[i(l,{loading:u(K),type:"primary",onClick:t[1]||(t[1]=a=>X(u(L),u(R)))},{default:o(()=>t[6]||(t[6]=[d("刷新日志",-1)])),_:1,__:[6]},8,["loading"]),p(i(k,{title:"全屏查看日志",class:"h-[40rem] mt-12px",content:u(E)},null,8,["content"]),[[I,u(K)]])])]),_:1},8,["modelValue"]),i(g,{title:"详情展示【".concat(u(L).name,"】"),modelValue:u(T),"onUpdate:modelValue":t[3]||(t[3]=a=>c(T)?T.value=a:null),area:70},{default:o(()=>[m("div",F,[i(C,{column:1,border:"",class:"max-h-[46rem] w-full overflow-auto table-descriptions"},{default:o(()=>[(r(!0),n(b,null,_(Object.entries(u(M)),(a,e)=>(r(),v(j,{key:e},{label:o(()=>[d(f(a[0]),1)]),default:o(()=>[m("span",{title:String(JSON.stringify(a[1])),class:"w-340px truncate inline-block"},f(a[1]),9,G)]),_:2},1024))),128))]),_:1})])]),_:1},8,["title","modelValue"])]),_:1})])}}}),[["__scopeId","data-v-d1f17202"]]);export{J as default};
