import{_ as h,u as y,o as C,a as x,b as i,c as a,d as e,t as u,n as M,w as m,e as S,f as k,g as _,r as b,h as v,i as z,v as A,j as B,F as I,k as L,l as V}from"./index-CG8CEDc4.js";const T={class:"preview-area"},E=["src"],N={key:1,class:"snapshot-placeholder"},j={class:"card-footer"},q={class:"device-main-info"},F={class:"device-id-text"},O={class:"device-meta"},U={class:"model-name"},Q=["disabled"],W={__name:"DeviceCard",props:{device:{type:Object,required:!0}},emits:["connect"],setup(c,{emit:o}){const l=c,r=o,p=y(),t=b(!1),s=_(()=>l.device.status==="online"?"online":"offline"),d=_(()=>l.device.status==="online"?"在线":"离线");function $(){t.value||r("connect",l.device.id)}function w(){t.value=!t.value}function D(){t.value=!1,confirm(`警告：确定要停止设备 "${l.device.id}" 上的 Agent 进程吗？停止后该设备将下线。`)&&p.quitAgent(l.device.id)}function f(){t.value&&(t.value=!1)}return C(()=>document.addEventListener("click",f)),x(()=>document.removeEventListener("click",f)),(ne,n)=>{var g;return i(),a("div",{class:"device-card",onClick:$},[e("div",T,[c.device.snapshot?(i(),a("img",{key:0,src:c.device.snapshot,class:"snapshot-img"},null,8,E)):(i(),a("div",N,[...n[2]||(n[2]=[e("span",{class:"vm-icon"},"💻",-1)])])),n[3]||(n[3]=e("div",{class:"overlay"},[e("span",{class:"play-hint"},"点击进入控制")],-1))]),e("div",j,[e("div",q,[e("h3",F,u(c.device.id),1),e("span",{class:M(["status-badge",s.value])},u(d.value),3)]),e("div",O,[e("span",U,u(((g=c.device.info)==null?void 0:g.model)||"Android VM"),1)]),e("button",{class:"menu-btn",onClick:m(w,["stop"]),title:"更多操作"},[...n[4]||(n[4]=[e("svg",{viewBox:"0 0 16 16",fill:"currentColor"},[e("circle",{cx:"4",cy:"8",r:"1.5"}),e("circle",{cx:"8",cy:"8",r:"1.5"}),e("circle",{cx:"12",cy:"8",r:"1.5"})],-1)])])]),t.value?(i(),a("div",{key:0,class:"card-menu",onClick:n[0]||(n[0]=m(()=>{},["stop"]))},[e("button",{class:"menu-item danger",onClick:D,disabled:c.device.status!=="online"},[...n[5]||(n[5]=[e("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[e("path",{d:"M8 2v6M12 4.5a6 6 0 11-8 0"})],-1),S(" 退出 Agent ",-1)])],8,Q)])):k("",!0),t.value?(i(),a("div",{key:1,class:"menu-overlay",onClick:n[1]||(n[1]=m(ie=>t.value=!1,["stop"]))})):k("",!0)])}}},G=h(W,[["__scopeId","data-v-f363bc9e"]]),H={class:"device-list-page"},J={class:"page-header"},K={class:"header-left"},P={class:"device-count"},R={class:"header-controls"},X={class:"size-control"},Y={class:"size-value"},Z={class:"grid-container"},ee={key:0,class:"state-view"},se={key:1,class:"state-view"},te={__name:"DeviceList",setup(c){const o=y(),l=b(280);let r=null;C(()=>{o.fetchDevices(),r=setInterval(()=>{o.fetchDevices()},1e4)}),x(()=>{r&&clearInterval(r)});function p(t){o.openWindow(t)}return(t,s)=>(i(),a("div",H,[e("header",J,[e("div",K,[s[2]||(s[2]=e("h2",{class:"page-title"},"所有虚机",-1)),e("span",P,u(v(o).devices.length)+" 台在线",1)]),e("div",R,[e("button",{class:"deploy-btn",onClick:s[0]||(s[0]=d=>t.router.push("/deploy"))}," 🚀 部署新设备 "),e("div",X,[s[3]||(s[3]=e("span",{class:"label"},"缩略图大小",-1)),z(e("input",{type:"range","onUpdate:modelValue":s[1]||(s[1]=d=>l.value=d),min:"150",max:"400",step:"10",class:"size-slider"},null,512),[[A,l.value]]),e("span",Y,u(l.value)+"px",1)])])]),e("main",Z,[v(o).loading&&v(o).devices.length===0?(i(),a("div",ee,[...s[4]||(s[4]=[e("div",{class:"spinner"},null,-1),e("p",null,"正在获取虚机列表...",-1)])])):v(o).devices.length===0?(i(),a("div",se,[...s[5]||(s[5]=[e("div",{class:"empty-icon"},"📵",-1),e("h3",null,"暂无在线虚机",-1),e("p",null,"请确保 Agent 已启动并注册到 Signaling Server",-1)])])):(i(),a("div",{key:2,class:"device-grid",style:B({gridTemplateColumns:`repeat(auto-fill, minmax(${l.value}px, 1fr))`})},[(i(!0),a(I,null,L(v(o).devices,d=>(i(),V(G,{key:d.id,device:d,onConnect:p},null,8,["device"]))),128))],4))])]))}},le=h(te,[["__scopeId","data-v-bbad44e0"]]);export{le as default};
