import{d as i,y as c}from"./index-7aa7f2ab.js";const r=i({id:"common",state:()=>({websocket:null,log_cache:[],log_cache_max_len:1e3,startTime:-1}),actions:{createWebSocket(){if(this.websocket)return;let t=window.location.protocol==="https:"?"wss":"ws",o="/api/live-log",s=window.location.port,e=`${t}://${window.location.hostname}:${s}${o}`;console.log("websocket url:",e),this.websocket=new WebSocket(e),this.websocket.onmessage=a=>{this.log_cache.push(a.data),this.log_cache.length>this.log_cache_max_len&&this.log_cache.shift()}},getLogCache(){return this.log_cache},getStartTime(){if(this.startTime!==-1)return this.startTime;c.get("/api/stat/start-time").then(t=>{this.startTime=t.data.data.start_time})}}});export{r as u};
