← Back
Editing: index70.js
import{K as e,aq as a,n as t,L as s,bv as n,b as o,p as r,at as l,u as i,aM as c,a6 as m,q as p,w as u,a8 as d,ag as _}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as v}from"./index103.js?v=VERSION_NUMBER";import{_ as f}from"./index130.js?v=VERSION_NUMBER";import{g as j,r as y,as as g,c as b,s as h,e as x,B as w,w as k,p as C,n as O,q as P,v as E,x as N,M as S,A as B,y as I,C as L,P as T,J as q}from"./base-lib.js?v=VERSION_NUMBER";import{c as D,a as R,d as V,g as A,u as M}from"./column.js?v=VERSION_NUMBER";import{b as J,g as F,s as U,c as z,d as K,f as W,h as G,u as H,a as Q,j as X}from"./useController6.js?v=VERSION_NUMBER";import{u as Y,S as Z}from"./useStore4.js?v=VERSION_NUMBER";import{u as $}from"./index141.js?v=VERSION_NUMBER";import{getNodeVersionList as ee,setDefaultEnv as ae,getNodeJsEnvironment as te,delNodeProject as se,getPackageManagers as ne,modifyNodeProject as oe,batchDelSite as re,batchStatus as le}from"./site.js?v=VERSION_NUMBER";import{l as ie,i as ce,o as me,h as pe}from"./validator.js?v=VERSION_NUMBER";const ue=o(),{siteInfo:de,isRefreshList:_e,activeType:ve}=Y(),{setSiteInfo:fe}=Z(),je=j((()=>!!de.value)),ye=y("0"),ge=y([]),be=g("_node_mask",!1),he=async()=>{var a;const t=await e({loading:"正在设置,请稍后...",request:ae({version:ye.value})});ue.request({status:null==(a=t.data)?void 0:a.status,msg:t.data.data||t.data.error_msg})},xe=async()=>{try{const{data:e}=await a({sName:"nodejs"});await ie({name:"nodejs",softData:e})}catch(e){}},we=()=>{de.value=null,t({title:"添加Node项目",area:80,component:()=>s((()=>import("./index362.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),showFooter:!0})},ke=()=>{t({title:"PM2监控",area:120,showFooter:!1,component:()=>s((()=>import("./index363.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)})},Ce=(e,a)=>{fe(e,a),t({isAsync:!0,title:"Node项目管理["+e.name+"] -- 添加时间["+e.addtime+"]",area:[87,71],component:()=>s((()=>import("./index364.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)})},Oe=async e=>{try{const{data:a}=await ne({version:e});return a.package_managers}catch(a){l(a)}},Pe=y({nodejs_versions:[],package_managers:[],user_list:[],maximum_memory:0}),Ee=async()=>{var e,a,t,s;try{const o=await te();return Object.assign(Pe.value,{...null==o?void 0:o.data,maximum_memory:(null==(e=null==o?void 0:o.data)?void 0:e.maximum_memory)||0,nodejs_versions:n(null==(a=null==o?void 0:o.data)?void 0:a.nodejs_versions,"array",[]),user_list:n(null==(t=null==o?void 0:o.data)?void 0:t.user_list,"array",[]),package_managers:n(null==(s=null==o?void 0:o.data)?void 0:s.package_managers,"array",[])}),o.data}catch(o){return Pe.value}},Ne=async a=>{a&&(await e({loading:"正在保存修改,请稍后...",request:oe(a),message:!0}),_e.value=!0)},Se=async(e,a,t,s,n,o)=>{const{label:r,value:l}=s,{enable:i,exclude:c}=o,m=new Map([["start","批量启动选中项目后,项目将正常访问"],["stop","批量停用选中的项目后,项目将会停止运行"],["restart","批量重启选中的项目后,项目将会重新启动"],["delete","批量删除选中的项目后,项目将无法恢复"]]);await e({title:"批量".concat(r),content:"".concat(m.get(l),",是否继续操作?"),column:[{label:"项目名称",prop:"name"},D()],onConfirm:async()=>{const e=await(async()=>{const e=new Map([["start",le],["stop",le],["restart",le]]).get(l);switch(l){case"start":case"stop":case"restart":if(e){const a=t.value.map((e=>e.project_config.pm2_name?{id:e.id,project_name:e.name,project_type:e.project_config.project_type||"nodejs",pm2_name:e.project_config.pm2_name}:{id:e.id,project_name:e.name,project_type:e.project_config.project_type||"nodejs"})),s=pe(!1,c,i,{params:{site_list:JSON.stringify(a),status:l,project_type:"NODE"}});return await e(s,ve.value)}case"delete":const a=t.value.map((e=>e.project_config.pm2_name?{id:e.id,name:e.name,project_type:e.project_config.project_type||"nodejs",pm2_name:e.project_config.pm2_name}:{id:e.id,name:e.name,project_type:e.project_config.project_type||"nodejs"})),s=pe(!1,c,i,{params:{project_type:ve.value.toUpperCase(),site_list:JSON.stringify(a)}});return await re(s)}})();_e.value=!0,n&&n();let{data:a}=ce(e.data);a=a.map((e=>({...e,name:e.name||e.project_name}))),me(a,{title:"".concat(r,"网站")})}})},Be={class:"content-mask"},Ie={class:"flex items-center mx-12px"},Le=b({__name:"index",setup(e){i();const{getSiteList:a,setSiteInfo:t}=Z(),{activeType:o,isRefreshList:l,siteInfo:j,searchWidth:y}=h(Z()),{BtOperation:g}=c({options:[{type:"button",label:"添加项目",active:!0,onClick:()=>{var e;if(!(null==(e=ge.value)?void 0:e.length))return xe();we()}},{type:"button",label:"Node版本管理器",onClick:xe},{type:"button",label:"PM2监控",onClick:ke}]}),b=$({key:"type_id",name:"Node分类",options:()=>[{label:"全部分类",value:"all"}],event:G,ignore:["0"],field:"type_name"}),D=d([{label:"启动项目",value:"start",event:Se},{label:"停用项目",value:"stop",event:Se},{label:"重启项目",value:"restart",event:Se},H(),Q({classList:X}),{label:"删除项目",value:"delete",event:Se}]),{BtTable:Y,BtPage:ae,BtRefresh:te,BtSearch:ne,BtColumn:oe,BtBatch:re,BtTableCategory:le,refresh:ie,config:ce}=m({request:e=>{const{type_id:t,...s}=e;return a({data:JSON.stringify({...s,type_id:p(t)||"all"===t?"":t})})},columns:[R({type:"page",key:"id"}),J({onClick:e=>{Ce(e)}}),F({type:o.value,onClick:(e,a)=>{if("setting"===a)return void Ce(e,"state");const t=e.run?"stop":"start";U(e,"restart"===a?a:t)}}),{label:"PID",isCustom:!0,render:e=>{const a=n(e.load_info,"object",{});if(0==Object.keys(a).length)return"--";let t=[];for(var s in e.load_info)e.load_info.hasOwnProperty(s)&&t.push(s);return t.join(",")}},{label:"CPU",isCustom:!1,render:e=>{const a=n(e.load_info,"object",{});if(0==Object.keys(a).length)return"--";let t=0;for(var s in e.load_info)t+=e.load_info[s].cpu_percent;return t.toFixed(2)+"%"}},{label:"内存",isCustom:!1,render:e=>{const a=n(e.load_info,"object",{});if(0==Object.keys(a).length)return"--";let t=0;for(var s in e.load_info)t+=e.load_info[s].memory_used;return u(t)}},V(),z(),A({table:"sites",width:200}),{label:"Node版本",isCustom:!0,render:e=>e.project_config.nodejs_version||"--"},K({onClick:e=>{Ce(e,"ssl")}}),M([{title:"设置",onClick:e=>{Ce(e)}},{title:"删除",onClick:e=>{(async e=>{await r({type:"default",title:"删除项目-".concat(e.name),content:"风险操作,此操作不可逆,删除【".concat(e.name,"】项目后您将无法管理该项目,是否继续操作?"),input:{content:"删除项目"}});try{let a=e.project_config,t={project_name:a.project_name,project_type:a.project_type||"nodejs"};a.pm2_name&&(t.pm2_name=a.pm2_name);const s=await se(t);ue.request(s),_e.value=!0}catch(a){}})(e)}}])],extension:[b,D],empty:()=>x("span",null,[w("您的列表为空,您可以"),x("span",{class:"bt-link",onClick:we},[w("添加一个项目")])])});return k(l,(async e=>{var a;if(e){if(await ie(),null==(a=j.value)?void 0:a.name){const e=ce.data.find((e=>e.name===j.value.name));e&&t(e)}l.value=!1}})),C((()=>{(async()=>{var e;try{const a=await ee();if(ge.value=[],!a.status)return void(be.value=!0);be.value=!1,null==(e=a.data)||e.forEach((e=>{e.setup&&ge.value.push({label:e.version,value:e.version}),1===e.is_default&&(ye.value=e.version)})),ge.value.unshift({label:"未设置",value:"0"})}catch(a){}})(),O((()=>{s((()=>import("./index362.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),s((()=>import("./index364.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)}))})),(e,a)=>{const t=f,s=_,n=v;return P(),E("div",null,[N(be)?(P(),S(t,{key:0},{content:B((()=>[I("div",Be,[a[3]||(a[3]=I("i",{class:"svgtofont-el-warning text-warning !text-[2.2rem] mr-4px"},null,-1)),a[4]||(a[4]=w(" 未安装Node版本管理器,")),I("span",{class:"bt-link",onClick:a[0]||(a[0]=(...e)=>N(xe)&&N(xe)(...e))},"点击安装")])])),_:1})):L("",!0),x(n,null,{"header-left":B((()=>[x(N(g)),I("div",Ie,[a[5]||(a[5]=I("span",{class:"mr-4px"},"命令行版本",-1)),x(s,{class:"!w-[10rem]",modelValue:N(ye),"onUpdate:modelValue":a[1]||(a[1]=e=>T(ye)?ye.value=e:null),options:N(ge),onChange:N(he)},null,8,["modelValue","options","onChange"])]),I("div",{class:"flex items-center ml-1rem",onClick:a[2]||(a[2]=(...e)=>N(W)&&N(W)(...e))},a[6]||(a[6]=[I("i",{class:"svgtofont-desired text-[1.6rem]"},null,-1),I("span",{class:"bt-link"},"需求反馈",-1)]))])),"header-right":B((()=>[x(N(le),{class:"!w-[140px] mr-[10px]"}),x(N(ne),{class:q(["mr-[10px]","!w-[".concat(N(y),"px]")]),placeholder:"请输入项目名称或备注"},null,8,["class"]),x(N(te),{class:"mr-[10px]"}),x(N(oe))])),content:B((()=>[x(N(Y))])),"footer-left":B((()=>[x(N(re))])),"footer-right":B((()=>[x(N(ae))])),_:1})])}}}),Te=Object.freeze(Object.defineProperty({__proto__:null,default:Le},Symbol.toStringTag,{value:"Module"}));export{Te as a,Ee as g,je as i,Pe as n,xe as o,Ne as s,Oe as u}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel