import{u as a,l as e,bK as t,z as s,x as l,b9 as u,M as o,aC as r}from"./utils-lib.js?v=20260328163632";import{B as i,au as d}from"./naive-ui.js?v=20260328163632";import{k as n,ao as c,ap as m,w as p,o as f,V as v,W as y,X as b,j as _,Z as g,Y as x,O as k,a3 as V,_ as w}from"./base-lib.js?v=20260328163632";const C={class:"flex flex-col text-[var(--text-color-2)]"},M={class:"mb-[12px] flex items-center"},h=n({__name:"index",props:{modelValue:{default:!1,type:Boolean},modelModifiers:{},name:{default:"",type:String},nameModifiers:{},rname:{default:"",type:String},rnameModifiers:{},tab:{default:"",type:String},tabModifiers:{},serviceData:{default:{},type:Object},serviceDataModifiers:{}},emits:c(["refresh"],["update:modelValue","update:name","update:rname","update:tab","update:serviceData"]),setup(n,{emit:c}){const h=m(n,"modelValue"),j=m(n,"name"),D=m(n,"rname"),S=m(n,"tab"),B=m(n,"serviceData"),O=c,{isWin:W}=a(),q={start:e("启动"),stop:e("停止"),restart:e("重启"),reload:e("重载配置")},z=async a=>{await s({title:e("{0}服务",[j.value]),icon:"warning-filled",content:e("您确定{0}{1}服务吗?",[q[a]," "+j.value])}),await l({loading:e("正在设置状态，请稍后..."),request:u({type:a,name:D.value||j.value}),success:async e=>{e.status?o.success(e.msg):o.msg({type:"error",message:e.msg,duration:0,showClose:!0}),500!==(null==e?void 0:e.code)&&(h.value="stop"!==a,O("refresh"))}})},K=async()=>{var a;if(!j.value||j.value.includes("php")&&W.value)return;const t=o.load(e("正在获取状态，请稍后..."));try{const e=await r({name:D.value||j.value});B.value=null==e?void 0:e.data,h.value=1===(null==(a=null==e?void 0:e.data)?void 0:a.status_code)}catch(s){}finally{t.close()}};return p((()=>S.value),(a=>{"server"===a&&K()})),f(K),(a,s)=>{const l=i,u=d;return v(),y("div",C,[b("span",M,[_(g(x(e)("当前状态：")),1),k(x(t),{modelValue:h.value,"onUpdate:modelValue":s[0]||(s[0]=a=>h.value=a),data:[x(e)("关闭"),x(e)("开启")]},null,8,["modelValue","data"])]),k(u,null,{default:V((()=>[h.value?(v(),w(l,{key:1,type:"default",onClick:s[2]||(s[2]=a=>z("stop"))},{default:V((()=>[_(g(x(e)("停止")),1)])),_:1})):(v(),w(l,{key:0,type:"default",onClick:s[1]||(s[1]=a=>z("start"))},{default:V((()=>[_(g(x(e)("启动")),1)])),_:1})),k(l,{type:"default",onClick:s[3]||(s[3]=a=>z("restart"))},{default:V((()=>[_(g(x(e)("重启")),1)])),_:1}),k(l,{type:"default",onClick:s[4]||(s[4]=a=>z("reload"))},{default:V((()=>[_(g(x(e)("重载配置")),1)])),_:1})])),_:1})])}}});export{h as _};
