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