import{u as y,r as k,s as w,v as b,A as m,n as v,b as _,o as $,k as S,w as c,f as i}from"./index.js";import{f as u,a as g,b as x}from"./common.js";const M={__name:"Status",props:{domain:String},setup(d){const f=d,{t}=y({useScope:"global"});let p=0;const n=k([]);w(()=>{h(),p=setInterval(h,1e3)}),b(()=>{clearInterval(p)});function r(a){let{days:s,hours:o,minutes:e,seconds:l}=x(a);return o<10&&(o="0"+o),e<10&&(e="0"+e),l<10&&(l="0"+l),s==0?`${o}:${e}:${l}`:`${s} ${t("str_label_days")} ${o}:${e}:${l}`}function h(){m.post("service_get_domain_status.html",`domain=${f.domain}&r=${Math.random()}`).then(({data:{code:a,data:s,error:o}})=>{if(a==0){let e=[];if(e.push({key:t("str_domain_runtime"),value:r(s.running_time)}),e.push({key:t("str_current_session"),value:s.current_session}),e.push({key:t("str_highest_session"),value:s.max_session}),e.push({key:t("str_24hour_session"),value:s.last24hour_session}),e.push({key:t("str_avg_sessionlen"),value:r(s.session_averagesec)}),e.push({key:t("str_longest_session"),value:r(s.session_maxsec)}),e.push({key:t("str_total_session"),value:s.total_session}),e.push({key:t("str_download_speed"),value:u(s.down_speed)}),e.push({key:t("str_avg_downspeed"),value:u(s.down_averagespeed)}),e.push({key:t("str_total_download"),value:g(s.down_bytes)}),e.push({key:t("str_total_downfile"),value:s.down_files}),e.push({key:t("str_upload_speed"),value:u(s.up_speed)}),e.push({key:t("str_avg_upspeed"),value:u(s.up_averagespeed)}),e.push({key:t("str_total_upload"),value:g(s.up_bytes)}),e.push({key:t("str_total_upfile"),value:s.up_files}),n.value.length===e.length)for(let l=0;l<e.length;l++)n.value[l].key=e[l].key,n.value[l].value=e[l].value;else n.value.length=0,e.forEach(l=>n.value.push(l))}else a===-1&&(v({message:o,grouping:!0,type:"error"}),m.logout())}).catch(a=>{v({message:a.message,grouping:!0,type:"error"})})}return(a,s)=>{const o=_("el-table-column"),e=_("el-table"),l=_("el-card");return $(),S(l,{shadow:"always"},{default:c(()=>[i(e,{data:n.value,"highlight-current-row":""},{default:c(()=>[i(o,{prop:"key",label:a.$t("title_statistics"),"min-width":67},null,8,["label"]),i(o,{prop:"value",label:a.$t("title_value"),"min-width":33},null,8,["label"])]),_:1},8,["data"])]),_:1})}}};export{M as default};
