← Back
Editing: index28.js
import{_ as e}from"./index103.js?v=VERSION_NUMBER";import{_ as a}from"./index112.js?v=VERSION_NUMBER";import{ay as t,u as s,n as l,L as n,K as o,aN as r,w as i,aO as c,M as u,p as m,aP as d,aQ as p,aR as _,aA as v,aS as g,aT as b,aU as f,c as h,J as k,ak as y,l as w,a0 as x,e as E}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as j}from"./index145.js?v=VERSION_NUMBER";import{k as N,r as S,U as C,c as D,w as T,p as q,n as L,a4 as R,G as I,q as M,v as O,e as A,A as P,y as U,x as V,B as J,H}from"./base-lib.js?v=VERSION_NUMBER";import{u as B,a as G,b as K,e as F,r as Q,C as W,t as z,o as X,N as Y}from"./useMethods.js?v=VERSION_NUMBER";import{u as Z}from"./use-socket-request.js?v=VERSION_NUMBER";import"./__commonjsHelpers__.js?v=VERSION_NUMBER";import"./column.js?v=VERSION_NUMBER";import"./index104.js?v=VERSION_NUMBER";const{refs:{customLimit:$,cpuAndMemData:ee,maxCPU:ae,maxMem:te,maxGpus:se}}=t(),{mainHeight:le,enterpriseRec:ne}=s(),oe=N({loading:!1,total:0,p:1,limit:Number(localStorage.getItem("dockercontainerlimit"))||20,usedList:[],search:""}),re=S([]),ie=C([]),ce=S([]),ue=S("all"),me=[{label:"启动",value:"start",event:B},{label:"重启",value:"restart",event:B},{label:"停止",value:"stop",event:B},{label:"强制停止",value:"kill",event:B},{label:"暂停",value:"pause",event:B},{label:"恢复",value:"unpause",event:B},{label:"删除",value:"delete",event:B}],de=[{active:!0,content:"创建容器",event:()=>G()},{content:"日志管理",event:()=>Ne()},{content:"清理容器",event:()=>Ce()},...ne.value?[{content:"安全检测",event:async()=>{l({title:"安全检测",area:70,component:()=>n((()=>import("./index142.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)})}}]:[]],pe=()=>{$.value.container=!0,localStorage.setItem("dockercontainerlimit",String(oe.limit)),je(!1)},_e=async e=>{o({loading:"正在获取容器目录,请稍候...",request:_({data:JSON.stringify({id:e.id})}),success:e=>{v("Path",e.data.path),window.location.href=window.location.origin+"/files"},error:e=>{u.error((null==e?void 0:e.msg)||"获取容器目录失败")}})},ve=async()=>{if(oe.p=1,""===oe.search)return oe.total=re.value.length,void je(!1);const e=oe.search.toLowerCase(),a=["name","id","image"],t=re.value.filter((t=>a.some((a=>{var s;return null==(s=t[a])?void 0:s.toLowerCase().includes(e)}))));oe.total=t.length,ie.value=K({limit:oe.limit,list:t,p:oe.p})||[]},ge=S(F({reNameEvent:e=>Q(e),realMonitorEvent:e=>W(e),terminalEvent:z,dirEvent:_e,logDataEvent:e=>Ne(e),deleteDataEvent:async e=>{try{await m({title:"删除容器【".concat(e.name,"】"),content:"删除容器【".concat(e.name,"】,是否继续操作?")}),o({loading:"正在删除容器,请稍候...",request:g({data:JSON.stringify({id:e.id})}),message:!0,success:je})}catch(a){}},conDetailEvent:X,setStatusEvent:async(e,a)=>{o({loading:"正在设置容器状态,请稍候...",request:p({data:JSON.stringify({id:e.id,status:a})}),message:!0,success:je})},openContainerBackups:e=>Se(e),openProxyDetails:e=>X(e,"proxy"),changeTaskTopEvent:async(e,a)=>{o({loading:"正在设置容器置顶,请稍候...",request:b({type:"top"==a?"add":"del",container_name:e.name}),message:!0,success:()=>{e.is_top="top"==a?1:0,xe()}})},moreEvent:(e,a)=>{switch(e){case"terminal":z(a);break;case"reName":Q(a);break;case"realMonitor":W(a);break;case"proxyDetails":X(a,"proxy");break;case"dir":_e(a);break;case"log":Ne(a)}},setStatusTitle:async e=>{var a;if("all"===e)return ue.value=e,await je();ie.value=(null==(a=ce.value[e])?void 0:a.map((e=>{const a=re.value.find((a=>a.id===e.id));return{...e,backup_count:(null==a?void 0:a.backup_count)||0,remark:(null==a?void 0:a.remark)||""}})))||[]},statusFilterKey:ue}));let be=null;const fe=async e=>{try{const a=e;a.data.container_stats_data&&ye(a.data),a.end&&(null==be||be.socketRequest({params:{model_index:"btdocker",mod_name:"container",def_name:"get_all_stats",ws_callback:"get_all_stats"},onMessage:fe}))}catch(a){}},he=async()=>{null==be||be.socketDestroy(),be=Z("/ws_model");null==be||be.socketRequest({params:{model_index:"btdocker",mod_name:"container",def_name:"get_all_stats",ws_callback:"get_all_stats"},onMessage:fe})},ke=e=>e.id,ye=e=>{if(!e.container_stats_data)return;const a=e.container_stats_data;ie.value.forEach((e=>{if("running"===e.status){const t=a.find((a=>a.id==e.id));t&&(ee.value[e.id]={cpu_usage:t.cpu_usage||0,mem_percent:t.mem_percent||0})}}))},we=()=>{null==be||be.socketDestroy(),be=null,oe.loading=!1,oe.total=0,oe.p=1,oe.search="",oe.usedList=[],oe.limit=Number(localStorage.getItem("dockercontainerlimit"))||20,re.value=[],ie.value=[],ce.value=[]},xe=()=>{re.value=re.value.sort(((e,a)=>1==e.is_top&&1!=a.is_top?-1:1!=e.is_top&&1==a.is_top?1:e.created_time>a.created_time?-1:1)),ie.value=K({limit:oe.limit,list:re.value,p:oe.p})||[]};let Ee=!0;const je=async e=>{!1!==e?(Ee&&(oe.loading=!0),await o({request:r(),data:{container_list:Array,grouped_by_status:Object,mem_total:Number,online_cpus:Number,gpu:Number},success:e=>{Ee=!1;const a=e.container_list;e.container_list.forEach((e=>{ee.value[e.id]={cpu_usage:0,mem_percent:0}})),re.value=a,oe.total=a.length,ie.value=K({...oe,list:a})||[],oe.loading=!1,ce.value=e,ae.value=e.online_cpus,te.value=Number(i(Number(e.mem_total),!1,0,"MB")),se.value=e.gpu||0}}),await o({request:c(),data:Array,success:e=>{re.value.forEach(((a,t)=>{const s=e.find((e=>e.id===a.id));s&&(a.backup_count=s.backup_count,a.remark=s.remark)})),he()}})):ie.value=K({...oe,list:re.value})||[]},Ne=(e={})=>{if(!re.value.length)return u.error("容器列表为空");l({component:()=>n((()=>import("./index143.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),title:"容器日志",area:92,compData:{row:e,list:re.value}})},Se=e=>l({component:()=>n((()=>import("./index144.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),title:"备份容器 - ["+e.name+"]",area:79,compData:{row:e}}),Ce=async()=>{await m({content:"将删除所有已停止、未使用的容器,是否继续?",title:"清理容器",width:"42rem",type:"check",check:{content:'删除<span class="text-danger">所有</span>容器,包含正在运行的容器',onConfirm:async e=>{oe.loading=!0,o({request:d({type:e?1:0}),message:!0,success:je,error:()=>{oe.loading=!1}})}}})},De={class:"relative container-table-tab"},Te={class:"flex items-center"},qe=E(D({__name:"index",setup(l,{expose:n}){const{refs:{refreshWs:o,isRefreshTableList:r,customLimit:i},resetRefresh:c}=t(),{mainHeight:u}=s(),m=S(null);return T((()=>o.value),(e=>{e&&(o.value=!1,he())})),T((()=>r.value),(e=>{e&&(c(),je())})),q((async()=>{ge.value=f(JSON.parse(localStorage.getItem("dockerContainerTableColumn")||"[]")||[],ge.value),je(),L((()=>{i.value.container||setTimeout((()=>{le.value>900?oe.limit=20:oe.limit=10}),0)}))})),n({init:je,destroy:we}),R((()=>we())),(t,s)=>{const l=j,n=h,o=k,r=y,i=w,c=x,d=a,p=e,_=I("bt-loading");return M(),O("div",De,[A(p,null,{"header-left":P((()=>[U("div",Te,[A(l,{options:V(de)},null,8,["options"]),A(n,{class:"ml-[1.6rem]",onClick:V(Y)},{default:P((()=>s[3]||(s[3]=[J("需求反馈")]))),_:1},8,["onClick"]),A(n,{class:"ml-[1.6rem]",href:"https://www.bt.cn/bbs/thread-140412-1-1.html"},{default:P((()=>s[4]||(s[4]=[J(">>使用帮助")]))),_:1})])])),"header-right":P((()=>[A(o,{class:"!w-[26rem] mr-1rem",modelValue:V(oe).search,"onUpdate:modelValue":s[0]||(s[0]=e=>V(oe).search=e),onSearch:V(ve),placeholder:"请输入容器名、ID、容器镜像"},null,8,["modelValue","onSearch"]),A(r,{name:"dockerContainerTableColumn",column:V(ge),tableRef:V(m)},null,8,["column","tableRef"])])),content:P((()=>[H(A(i,{ref_key:"containerTable",ref:m,key:"containerTable",column:V(ge),data:V(ie),"row-key":V(ke),description:"容器列表为空","max-height":V(u)-230},null,8,["column","data","row-key","max-height"]),[[_,V(oe).loading],[_,"正在加载容器列表,请稍后...","title"]])])),"footer-left":P((()=>[A(c,{"table-ref":V(m),options:V(me)},null,8,["table-ref","options"])])),"footer-right":P((()=>[A(d,{page:V(oe).p,"onUpdate:page":s[1]||(s[1]=e=>V(oe).p=e),row:V(oe).limit,"onUpdate:row":s[2]||(s[2]=e=>V(oe).limit=e),useStorage:!1,total:V(oe).total,onChange:V(pe)},null,8,["page","row","total","onChange"])])),_:1})])}}}),[["__scopeId","data-v-7a068085"]]);export{qe as default}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel