← Back
Editing: index72.js
import{at as e,n as a,L as t,K as s,b as n,u as r,aM as i,a6 as l,q as o,w as p,a8 as c,c as u}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as m}from"./index103.js?v=VERSION_NUMBER";import{u as v}from"./index141.js?v=VERSION_NUMBER";import{j as d,as as _,r as h,g as y,c as f,s as g,e as w,B as j,w as b,p as x,n as k,q as P,v as C,A as T,x as O,y as E,J as q}from"./base-lib.js?v=VERSION_NUMBER";import{f as I,i as S,o as L,h as R}from"./validator.js?v=VERSION_NUMBER";import"./index.vue_vue_type_style_index_0_scoped_b3c4124c_lang.js?v=VERSION_NUMBER";import{c as A,a as D,d as M,g as B,u as V}from"./column.js?v=VERSION_NUMBER";import{b as N,g as J,c as z,d as U,f as F,h as G,s as H,i as K,u as W,a as Y,j as $}from"./useController6.js?v=VERSION_NUMBER";import{u as Q,S as X}from"./useStore4.js?v=VERSION_NUMBER";import{getPyVersion as Z,getPythonEnvironment as ee,changeProjectConf as ae,createPythonProject as te,getPythonAppInfo as se,getPythonProjectInfo as ne,pythonRecreateProject as re,advanceCheckPort as ie,batchStatus as le,batchDelSite as oe}from"./site.js?v=VERSION_NUMBER";const pe=d("SITE-PYTHON-STORE",(()=>({checkPythonVersion:async()=>{try{const e=await Z();return{data:e.data,status:e.status}}catch(a){e(a)}}}))),ce=n(),{activeType:ue,isRefreshList:me,siteInfo:ve,rowData:de}=Q(),{getClassList:_e,getProjectConfig:he,addGeneralProject:ye,getRootUser:fe,setSiteInfo:ge}=X(),{checkPythonVersion:we}=pe(),je=_("_python_mask",!1),be=()=>{ve.value=null,a({title:"添加Python项目",area:[68],component:()=>t((()=>import("./index367.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),showFooter:!0})},xe=e=>{a({isAsync:!0,title:"Python环境管理",area:105,component:()=>t((()=>import("./index368.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),onCancel:()=>{"function"==typeof e&&e()}})},ke=e=>{a({title:"终端",area:[90,50],isAsync:!0,showFooter:!1,component:()=>t((()=>import("./index369.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{hostInfo:{pj_name:e.name},row:e,cmd:e.shell_active}})},Pe=async(e,s="")=>{try{if(["running","failure"].includes(e.project_config.prep_status))return"failure"===e.project_config.prep_status&&await re({name:e.name}),a({isAsync:!0,title:"正在创建Python项目,请耐心等候...",area:52,component:()=>t((()=>import("./index370.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{type:"createPythonProject",logPath:"/www/server/python_project/vhost/logs/".concat(e.name,".log"),endMsg:"尝试启动项目",failMsg:"环境准备失败",successMsg:"创建成功",isClear:!0,completeEvent:async(e,a)=>{e||ce.error("环境准备失败"),me.value=!0,a()}}});ge(e,s),a({title:"Python项目管理["+e.name+"] -- 添加时间["+e.addtime+"]",area:[84,76],component:()=>t((()=>import("./index371.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)})}catch(n){}},Ce=async()=>{try{const e=await s({request:ee({sort_not_use:1})});e.status||(ce.error(e.msg),Ee.value=[]),Ee.value=e.data.env_list}catch(e){return{data:[],total:0}}},Te=e=>{switch(e){case"venv":return"虚拟环境";case"conda":return"Conda环境";case"system":return"系统级环境"}},Oe=h([]),Ee=h([]),qe=h([]),Ie=y((()=>{var e;return null==(e=ve.value)?void 0:e.id}));h([]);const Se=h({envType:0,rfile:"",pjname:"",port:"",path:"",framework:"",stype:"command",xsgi:"wsgi",requirement_path:"",auto_run:!1,venv_path:"",version:"",parm:"",env:"",envPath:"",app:"",processes:"",threads:"",user:"www",is_http:!0,listenMsg:"",initialize:"",python_bin:""}),Le=async()=>{try{await Ce();const a=await fe();if(qe.value=a.data,Ie.value){const a=await he({data:JSON.stringify({name:ve.value.name})}),{project_config:t,listen:s,pyenv_data:n}=a.data,{call_app:r,env_file:i,env_list:l,stype:o,project_cmd:p}=t;i&&(Se.value.envPath=i,Se.value.envType=2),(null==l?void 0:l.length)>0&&(e=l,Se.value.env=e.map((e=>e.k+"="+e.v)).join("\n"),Se.value.envType=1,Se.value.envType=1),Object.assign(Se.value,{...t,app:r,parm:"command"===o?p:"",python_bin:n.bin_path}),!s.includes(Number(Se.value.port))&&s.length>0&&(Se.value.listenMsg="当前监听端口".concat(s.join(",")))}}catch(a){}var e},Re=()=>{Object.assign(Se.value,{envType:0,rfile:"",pjname:"",port:"",path:"",framework:"",stype:"command",xsgi:"wsgi",requirement_path:"",auto_run:!1,venv_path:"",version:"",parm:"",env:"",envPath:"",app:"",processes:"",threads:"",user:"www",is_http:!0,listenMsg:"",initialize:"",python_bin:""})},Ae=async e=>{try{if(!Ie.value&&"command"!==e.stype){const a=await(async e=>{if(!e.port)return!1;try{const a=await ie({port:e.port},"python");return a.status||(ce.request(a),e.port=""),a.status}catch(a){}})(e);if(!a)return ce.error("端口被占用,请更换端口"),!1}let{pjname:a,port:t,path:n,version:r,parm:i,framework:l,requirement_path:o,envPath:p,stype:c,rfile:u,app:m,initialize:v,processes:d,threads:_,is_http:h,user:y,auto_run:f,envType:g,env:w,xsgi:j}=e;const b="command"!==c;1===g&&(w=(e=>{let a=e.split("\n").filter((e=>""!==e)),t=[];return a.forEach((e=>{let a=e.split("=");t.push({k:a[0],v:a[1]})})),t})(w));let x={pjname:a,port:t,stype:c,path:n,user:y,requirement_path:o,env_file:2===g?p:"",env_list:JSON.stringify(1===g?w:[]),framework:l,project_cmd:b?void 0:i,xsgi:b?j:void 0,rfile:b?u:void 0,call_app:b?m:void 0,python_bin:Se.value.python_bin};Ie.value?x={...x,processes:d,threads:_,is_http:h,auto_run:f}:x.initialize=v;const k={data:JSON.stringify(Ie.value?{name:ve.value.name,data:x}:x)},P=Ie.value?ae:te,C=await s({loading:"正在提交,请稍后...",request:P(k),message:!0});return me.value=!0,C.status}catch(a){}},De=()=>{I({type:"dir",path:Se.value.path,change:e=>{var a;if(e){Se.value.path=e;let t=null==(a=e.substring(e.lastIndexOf("/")+1))?void 0:a.replace(/\./g,"_").replace(/\/\//g,"/");Se.value.pjname=t,Je()}}})},Me=()=>{I({type:"file",path:Se.value.requirement_path,change:e=>{e&&(Se.value.requirement_path=e)}})},Be=()=>{I({type:"file",path:Se.value.rfile,change:e=>{Se.value.rfile=e,Ne()}})},Ve=()=>{I({type:"file",path:Se.value.envPath,change:e=>{Se.value.envPath=e}})},Ne=async()=>{try{const e=await se({runfile:Se.value.rfile});if(!e.status)return void ce.request(e);const{framework:a,xsgi:t,call_app:s}=e.data;a&&(Se.value.framework=e.data.framework),t&&(Se.value.xsgi=e.data.xsgi),s&&(Se.value.app=e.data.call_app)}catch(a){e(a)}},Je=async()=>{try{const e=Se.value.path,a=await ne({path:e});if(!a.status)return void ce.request(a);const{framework:t,requirement_path:s,runfile:n,xsgi:r,call_app:i}=a.data;t&&(Se.value.framework=a.data.framework),Se.value.requirement_path=s?a.data.requirement_path:"",n&&(Se.value.rfile=a.data.runfile),r&&(Se.value.xsgi=a.data.xsgi),i&&(Se.value.app=a.data.call_app)}catch(a){e(a)}},ze=async(e,a,t,s,n,r)=>{const{label:i,value:l}=s,{enable:o,exclude:p}=r,c=new Map([["start","批量启动选中项目后,项目将正常访问"],["stop","批量停用选中的项目后,项目将会停止运行"],["restart","批量重启选中的项目后,项目将会重新启动"],["delete","批量删除选中的项目后,项目将无法恢复"]]);await e({title:"批量".concat(i),content:"".concat(c.get(l),",是否继续操作?"),column:[{label:"项目名称",prop:"name"},A()],onConfirm:async()=>{const e=await(async()=>{const e=new Map([["start",le],["stop",le],["restart",le],["delete",oe]]).get(l);switch(l){case"start":case"stop":case"restart":if(e){const a=t.value.map((e=>({project_name:e.name}))),s=R(!1,p,o,{params:{site_list:JSON.stringify(a),status:l,project_type:ue.value.toUpperCase()}});return await e(s,ue.value)}case"delete":if(e){const a=R(t.value,p,o,{params:{project_type:ue.value.toUpperCase()}});return await e(a)}}})();me.value=!0,n&&n();let{data:a}=S(e.data);a=a.map((e=>({...e,name:e.name||e.project_name}))),L(a,{title:"".concat(i,"网站")})}})},Ue={class:"flex items-center ml-[12px]"},Fe=f({__name:"index",setup(a){r();const{getSiteList:s,setSiteInfo:n}=X(),{activeType:d,isRefreshList:_,siteInfo:h,searchWidth:y}=g(X()),{BtOperation:f}=i({options:[{type:"button",label:"添加项目",active:!0,onClick:be},{type:"button",label:"Python环境管理",onClick:xe}]}),I=v({key:"type_id",name:"Python分类",options:()=>[{label:"全部分类",value:"all"}],event:G,ignore:["0"],field:"type_name"}),S=c([{label:"启动项目",value:"start",event:ze},{label:"停用项目",value:"stop",event:ze},{label:"重启项目",value:"restart",event:ze},W(),Y({classList:$}),{label:"删除项目",value:"delete",event:ze}]),{BtTable:L,BtPage:R,BtRefresh:A,BtSearch:Q,BtColumn:Z,BtBatch:ee,BtTableCategory:ae,refresh:te,config:se}=l({request:e=>{const{type_id:a,...t}=e;return s({data:JSON.stringify({...t,type_id:o(a)||"all"===a?"":a})})},columns:[D({type:"page",key:"id"}),N({onClick:Pe}),J({onClick:(e,a)=>{if("setting"===a)return void Pe(e,"state");const t=e.run?"stop":"start";H(e,"restart"===a?a:t)}}),{label:"PID",isCustom:!1,render:e=>{var a,t;return o(e.pids)||0===(null==(a=e.pids)?void 0:a.length)?"--":(null==(t=e.pids)?void 0:t.join(","))||"--"}},{label:"监听端口",isCustom:!1,render:e=>{var a,t;return o(e.listen)||0===(null==(a=e.listen)?void 0:a.length)?"--":(null==(t=e.listen)?void 0:t.join(","))||"--"}},{label:"CPU",isCustom:!1,render:e=>o(e.cpu)?"--":e.cpu.toFixed(2)+"%"},{label:"内存",isCustom:!1,render:e=>o(e.mem)?"--":p(e.mem)},M(),z(),B({table:"sites",width:200}),U({onClick:e=>Pe(e,"ssl")}),V([{title:"终端",onClick:ke},{title:"设置",onClick:e=>Pe(e)},{title:"模块",onClick:e=>Pe(e,"envManager")},{title:"删除",onClick:e=>{K(e,d.value)}}])],extension:[I,S],empty:()=>w("span",null,[j("您的列表为空,您可以"),w("span",{class:"bt-link",onClick:be},[j("添加一个项目")])])});return b(_,(async e=>{var a;if(e){if(await te(),null==(a=h.value)?void 0:a.name){const e=se.data.find((e=>e.name===h.value.name));e&&n(e)}_.value=!1}})),x((()=>{(async()=>{try{const e=await we();je.value=!1,e.data.cpy_installed.length||e.data.pypy_installed.length||(je.value=!0),Oe.value=e.data.cpy_installed.concat(e.data.pypy_installed)}catch(a){e(a)}})(),k((()=>{t((()=>import("./index367.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),t((()=>import("./index371.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)}))})),(e,a)=>{const t=u,s=m;return P(),C("div",null,[w(s,null,{"header-left":T((()=>[w(O(f)),E("div",Ue,[w(t,{href:"https://www.bt.cn/bbs/thread-144409-1-1.html"},{default:T((()=>a[1]||(a[1]=[j(" Python项目教程 ")]))),_:1}),a[2]||(a[2]=E("i",{class:"svgtofont-el-link text-primary text-[1.6rem] ml-[4px]"},null,-1))]),E("div",{class:"flex items-center ml-1rem <xl:hidden",onClick:a[0]||(a[0]=(...e)=>O(F)&&O(F)(...e))},a[3]||(a[3]=[E("i",{class:"svgtofont-desired text-[1.6rem]"},null,-1),E("span",{class:"bt-link"},"需求反馈",-1)]))])),"header-right":T((()=>[w(O(ae),{class:"!w-[140px] mr-[10px]"}),w(O(Q),{class:q(["mr-[10px]","!w-[".concat(O(y),"px]")]),placeholder:"请输入项目名称或备注"},null,8,["class"]),w(O(A),{class:"mr-[10px]"}),w(O(Z))])),content:T((()=>[w(O(L))])),"footer-left":T((()=>[w(O(ee))])),"footer-right":T((()=>[w(O(R))])),_:1})])}}}),Ge=Object.freeze(Object.defineProperty({__proto__:null,default:Fe},Symbol.toStringTag,{value:"Module"}));export{Re as $,Ie as a,De as b,Je as c,Be as d,Ee as e,Ne as f,Ce as g,Ve as h,Le as i,Me as j,Te as k,Ge as l,xe as o,Se as p,Ae as s,qe as u}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel