import{l as a,e,aJ as s,aC as t,M as l,h as n,f as i,at as r,z as o,x as c,bi as u,_ as d}from"./utils-lib.js?v=20260328163632";import{k as v,ao as p,c as m,r as f,ap as _,w as g,o as y,V as h,_ as b,a3 as w,Y as x,U as I,l as k,W as j,X as q,O as C,Z as z,K as B,a1 as W,aE as F,aF as M}from"./base-lib.js?v=20260328163632";import{g as R,A as S,B as V}from"./naive-ui.js?v=20260328163632";const Z={class:"flex items-center justify-between"},A={class:"h-[22px] w-[22px] flex overflow-hidden justify-center items-center status-icon"},D=d(v({__name:"index",props:p({pluginInfo:{default:()=>({name:"",version:"",status_code:1,start_type:0})},isRequest:{type:Boolean,default:!0}},{pluginInfo:{default:{name:"",version:"",status_code:1,start_type:0}},pluginInfoModifiers:{}}),emits:["update:pluginInfo"],setup(d){const v=d,p=m((()=>["zh","cht"].includes(e.value)?100:180)),D=f(!1),E=f(!1),J=f(0),K=_(d,"pluginInfo"),O={stop:a("停止"),start:a("启动"),restart:a("重启"),reload:a("重载")},U={"FileZilla Server":"ftpserver",W3SVC:"iis",mysqld:"mysql"},X=m((()=>O[1===K.value.status_code?"stop":"start"])),Y=m((()=>{var a,e;return!!s(null==(a=K.value)?void 0:a.status_code)||1===(null==(e=K.value)?void 0:e.status_code)}));g((()=>v.pluginInfo),(a=>{D.value=!1,a&&(K.value=a,D.value=!0)}),{immediate:!0,deep:!0});const $=async()=>{try{E.value=!0;const a=await t({name:K.value.name||K.value.service_name});404!==a.data.code&&500!==a.data.code||(a.data={name:K.value.name||K.value.service_name,status_code:-1}),500===a.data.code&&l.error(a.data.msg),K.value=a.data}catch(a){}finally{E.value=!1}},G=()=>{r({name:U[K.value.service_name]||K.value.service_name})},H=async e=>{if(-1===K.value.status_code)return l.error(a("当前插件未安装，请先安装"));try{const s=O[e],t=K.value.version;await o({title:s+t,icon:"warning-filled",content:a("你确定要{0}服务，是否继续？",[s+t])}),await c({loading:E,request:u({name:U[K.value.service_name]||K.value.service_name,type:e}),message:!0,success:()=>{$()}})}catch(s){}},L=()=>{J.value=document.body.clientWidth};return y((()=>{v.pluginInfo.version&&v.isRequest&&$(),L(),window.onresize=L})),(e,s)=>{const t=S,l=V,r=R,o=I("bt-loading");return h(),b(r,{placement:"top-start",width:x(p),trigger:"hover"},{trigger:w((()=>[k((h(),j("div",F(M(e.$attrs)),[x(D)?(h(),b(l,{key:0,type:x(Y)?"default":"error",class:"plugin-status-btn",plain:"",onClick:G},{default:w((()=>[q("div",{class:B(["h-full inline-block flex items-center",x(Y)?"hover:text-primary":"hover:text-danger"])},[q("span",A,[C(x(n),{src:"/soft_ico/ico-".concat(U[d.pluginInfo.service_name]||d.pluginInfo.service_name||"defalut",".png"),class:"inline-block",alt:x(a)("软件图标"),previewDisabled:!0,type:"images"},null,8,["src","alt"])]),q("span",null,z(K.value.title),1),q("span",null,z(K.value.version),1),C(x(i),{icon:"icon-"+(x(Y)?"start":"stop"),class:B(["ml-[4px]",x(Y)?"!text-primary":"!text-danger"])},null,8,["icon","class"])],2)])),_:1},8,["type"])):W("",!0)],16)),[[o,x(E)],[o,"small","size"]])])),default:w((()=>[q("div",Z,[q("span",{class:"bt-link",onClick:s[0]||(s[0]=a=>H(x(Y)?"stop":"start"))},z(x(X)),1),C(t,{vertical:""}),q("span",{class:"bt-link",onClick:s[1]||(s[1]=a=>H("restart"))},z(x(a)("重启")),1)])])),_:1},8,["width"])}}}),[["__scopeId","data-v-7e7ac3c4"]]);export{D as B};
