import{c as a,X as s,r as e,Y as t,g as n,w as l,q as i,H as u,v as o,N as r,B as c,I as p,y as d,x as v,z as m,e as f,A as g,K as _,D as y,bi as b,bj as h,G as w,az as x}from"./base-lib.js?v=1761009159";import{aH as k,p as I,P as j,bL as N,f as q,d as C,Z as z,b1 as B,_ as R}from"./utils-lib.js?v=1761009159";import{_ as H}from"./index106.js?v=1761009159";import{l as A}from"./validator.js?v=1761009159";const D={class:"flex items-center justify-center"},G={class:"h-[2.2rem] w-[2.2rem] flex overflow-hidden justify-center items-center status-icon <2xl:hidden"},K={class:"<2xl:hidden"};var L=(a=>(a.stop="停止",a.start="启动",a.restart="重启",a.reload="重载",a))(L||{});const M=R(a({__name:"index",props:s({pluginInfo:{default:()=>({title:"",name:"defalut",status:!1,version:"",admin:!1,setup:!1,s_version:"",s_status:!1})},pluginName:{default:"defalut"},isRequest:{type:Boolean,default:!0}},{pluginInfo:{default:{title:"",name:"",status:!0,version:"",admin:!1,s_version:""}},pluginInfoModifiers:{}}),emits:["update:pluginInfo"],setup(a){const s=a,R=e(!1),M=e(!1),P=e(0),T=e(!1),W=t(a,"pluginInfo"),X=n(()=>L[W.value.s_status?"stop":"start"]);l(()=>s.pluginInfo,a=>{if(R.value=!1,!s.isRequest){if(z(a,"s_status"))W.value={...a};else{const{title_en:s,name:e,version:t,admin:n,s_version:l,status:i}=a;W.value={title:s,name:e,status:i,version:t,admin:n,s_version:l,s_status:i}}R.value=!0}},{immediate:!0,deep:!0});const Y=()=>{A({name:W.value.name})},Z=async a=>{try{const e=L[a],t=s.pluginInfo.s_version;await I({title:e+t,icon:"warning-filled",content:"你确定要".concat(e).concat(t,"服务，是否继续？")}),await j({loading:M,request:N({name:t,type:a}),message:!0,success:async()=>{await(async()=>{try{const a=["nginx","apache","openlitespeed"].includes(W.value.name)?"web":"pureftpd"===W.value.name?"pure-ftpd":W.value.name,{data:s}=await B({name:a});setTimeout(()=>{W.value=s,T.value=!0},100)}catch(a){W.value.status=!1}})(),T.value=!0}})}catch(e){}},$=()=>{P.value=document.body.clientWidth};return i(()=>{(s.pluginInfo.title||s.pluginName)&&s.isRequest&&(async()=>{try{M.value=!0;const{data:a}=await k({sName:s.pluginInfo.name||s.pluginName});W.value=a,T.value=!0}catch(a){W.value.s_status=!1,T.value=!0}finally{M.value=!1,R.value=!1}})(),$(),window.onresize=$}),(a,s)=>{const e=H,t=q,n=C,l=w,i=x,k=u("bt-loading");return o(),r(i,{placement:"top-start",width:"redis"===W.value.name?140:200,class:"","popper-class":"white-tips-popover",trigger:"hover"},{reference:c(()=>[p((o(),v("div",b(h(a.$attrs)),[d(R)?(o(),r(l,{key:0,type:W.value.s_status?"default":"danger",class:"plugin-status-btn",plain:"",onClick:Y},{default:c(()=>[m("div",{class:_(["h-full inline-block flex items-center",W.value.s_status?"hover:text-primary":"hover:text-danger"])},[m("span",G,[f(t,{src:"/static/icons/soft/ico-".concat(W.value.name||a.pluginName||"defalut",".svg"),class:"inline-block",all:!0},null,8,["src"])]),m("span",null,g(W.value.title),1),m("span",K," "+g(W.value.version),1),f(n,{icon:"icon-"+(W.value.s_status?"start":"stop"),class:_(["ml-[4px]",W.value.s_status?"!text-primary":"!text-danger"])},null,8,["icon","class"])],2)]),_:1},8,["type"])):y("",!0)],16)),[[k,d(M)],[k,"small","size"]])]),default:c(()=>[m("div",D,[m("span",{class:"bt-link",onClick:s[0]||(s[0]=a=>Z(W.value.s_status?"stop":"start"))},g(d(X)),1),f(e),m("span",{class:"bt-link",onClick:s[1]||(s[1]=a=>Z("restart"))},"重启"),f(e),m("span",{class:"bt-link",onClick:s[2]||(s[2]=a=>Z("reload"))},"重载"),"redis"!==W.value.name?(o(),r(e,{key:0})):y("",!0),"redis"!==W.value.name?(o(),v("span",{key:1,class:"bt-link",onClick:s[3]||(s[3]=a=>d(A)({name:W.value.name}))},"告警设置")):y("",!0)])]),_:1},8,["width"])}}}),[["__scopeId","data-v-ef61e40a"]]);export{M as B};
