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