diff --git a/assets/js/joe.census.js b/assets/js/joe.census.js index da6a27e..b4b664b 100644 --- a/assets/js/joe.census.js +++ b/assets/js/joe.census.js @@ -8,6 +8,11 @@ document.addEventListener('DOMContentLoaded', () => { i = Math.floor(Math.log(bytes) / Math.log(k)); return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; }; + /* 转换内存 */ + const megaknotsToSize = (limit) => { + if (limit < 1024) return parseInt(limit) + ' MB' + return parseInt(limit / 1024) + ' GB' + } const categories = []; const upSeries = []; const downSeries = []; @@ -27,6 +32,8 @@ document.addEventListener('DOMContentLoaded', () => { success(res) { if (!res.status) Qmsg.warning('服务器接口异常!'); { + $('.joe_census__server-item .count .core').html(`${res.cpu[1]} 核`); + $('.joe_census__server-item .count .ram').html(`${megaknotsToSize(res.memory.memTotal)}`); $('.joe_census__server-item .count .up').html(`总发送:${bytesToSize(res.upTotal)}`); $('.joe_census__server-item .count .down').html(`总接收:${bytesToSize(res.downTotal)}`); const stamp = new Date(); diff --git a/assets/js/joe.census.min.js b/assets/js/joe.census.min.js index 2be6652..7ad2720 100644 --- a/assets/js/joe.census.min.js +++ b/assets/js/joe.census.min.js @@ -1 +1 @@ -document.addEventListener("DOMContentLoaded",()=>{{const e=t=>{if(!t)return"0 B";const e=1e3,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(e));return(t/Math.pow(e,a)).toPrecision(3)+" "+o[a]},o=[],a=[],n=[],i=document.querySelector("#flow"),l=document.querySelector("#work"),s=i&&echarts.init(i),r=l&&echarts.init(l);function t(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"server_status"},success(i){i.status||Qmsg.warning("服务器接口异常!");{$(".joe_census__server-item .count .up").html(`总发送:${e(i.upTotal)}`),$(".joe_census__server-item .count .down").html(`总接收:${e(i.downTotal)}`);const t=new Date,l=String(t.getHours()).padStart(2,0),r=String(t.getMinutes()).padStart(2,0),c=String(t.getSeconds()).padStart(2,0),d=`${l}:${r}:${c}`;o.push(d),a.push(i.up),n.push(i.down),o.length>5&&o.shift(),a.length>5&&a.shift(),n.length>5&&n.shift(),s.setOption({title:{subtext:"单位 KB/s"},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},xAxis:{axisTick:{show:!1},type:"category",boundaryGap:!1,data:o},yAxis:{type:"value"},series:[{type:"line",name:"上行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#f39494",areaStyle:{color:"#f39494"},lineStyle:{width:2,color:"#f39494"}}},stack:"总量",data:a},{type:"line",name:"下行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#9dd3e8",areaStyle:{color:"#9dd3e8"},lineStyle:{width:2,color:"#9dd3e8"}}},stack:"总量",data:n}]})}{const t=i.cpu[0],e=Math.round(i.memory.memRealUsed/i.memory.memTotal*1e3)/10,o=Math.round(i.memory.memCached/i.memory.memTotal*1e3)/10,a=Math.round(i.memory.memBuffers/i.memory.memTotal*1e3)/10,n=Math.round(i.load.one/i.load.max*100)>100?100:Math.round(i.load.one/i.load.max*100);r.setOption({title:{subtext:"单位 百分比"},tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:["CPU占用","内存占用","系统缓冲","内存缓冲","系统负载"]},yAxis:{type:"value"},series:{data:[{name:"CPU占用",value:t,itemStyle:{color:"#b3c25a"}},{name:"内存占用",value:e,itemStyle:{color:"#67b580"}},{name:"系统缓冲",value:a,itemStyle:{color:"#86ba71"}},{name:"内存缓冲",value:o,itemStyle:{color:"#feb041"}},{name:"系统负载",value:n,itemStyle:{color:"#fd7e55"}}],type:"bar",showBackground:!0,label:{show:!0,color:"#ffffff",formatter:t=>`${t.data.value} %`},backgroundStyle:{color:"rgba(180, 180, 180, 0.2)"}}})}setTimeout(t,2e3)}})}i&&l&&t()}{const t=document.querySelector("#category"),e=echarts.init(t),o=[];$(".joe_census__basic-item.category ul li").each((t,e)=>{o.push({name:e.getAttribute("data-name"),value:e.getAttribute("data-value")})}),e.setOption({tooltip:{trigger:"item"},series:[{type:"pie",roseType:"area",itemStyle:{borderRadius:8},data:o}]})}{const t=document.querySelector("#lately"),e=echarts.init(t);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"comment_lately"},success(t){e.setOption({title:{subtext:"单位 数量"},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:t.categories},yAxis:{type:"value"},series:{name:"数量",itemStyle:{normal:{color:"#91cc75",lineStyle:{width:2,color:"#91cc75"}}},data:t.series,type:"line",smooth:!0}})}})}{let t=0;function e(){"loading..."!==$(".joe_census__filing .button").html()&&$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"article_filing",page:++t},success(t){if(!t.length)return $(".joe_census__filing .item.load").remove(),Qmsg.warning("没有更多内容了");let e="";t.forEach(t=>{e+=`\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
${t.date}
\n\t\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\t\t${t.list.map(t=>`
  1. ${t.title}
  2. `).join("")}\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t`}),$("#filing").append(e),$(".joe_census__filing .button").html("加载更多")}})}e(),$(".joe_census__filing .content").on("click",".panel",function(){const t=$(this).parents(".content");t.find(".panel").not($(this)).removeClass("in"),t.find(".panel-body").not($(this).siblings(".panel-body")).stop().hide("fast"),$(this).toggleClass("in").siblings(".panel-body").stop().toggle("fast")}),$(".joe_census__filing .button").on("click",function(){e(),$(this).html("loading...")})}}); \ No newline at end of file +document.addEventListener("DOMContentLoaded",()=>{{const e=t=>{if(!t)return"0 B";const e=1e3,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(e));return(t/Math.pow(e,a)).toPrecision(3)+" "+o[a]},o=t=>t<1024?parseInt(t)+" MB":parseInt(t/1024)+" GB",a=[],n=[],i=[],l=document.querySelector("#flow"),s=document.querySelector("#work"),r=l&&echarts.init(l),c=s&&echarts.init(s);function t(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"server_status"},success(l){l.status||Qmsg.warning("服务器接口异常!");{$(".joe_census__server-item .count .core").html(`${l.cpu[1]} 核`),$(".joe_census__server-item .count .ram").html(`${o(l.memory.memTotal)}`),$(".joe_census__server-item .count .up").html(`总发送:${e(l.upTotal)}`),$(".joe_census__server-item .count .down").html(`总接收:${e(l.downTotal)}`);const t=new Date,s=String(t.getHours()).padStart(2,0),c=String(t.getMinutes()).padStart(2,0),m=String(t.getSeconds()).padStart(2,0),d=`${s}:${c}:${m}`;a.push(d),n.push(l.up),i.push(l.down),a.length>5&&a.shift(),n.length>5&&n.shift(),i.length>5&&i.shift(),r.setOption({title:{subtext:"单位 KB/s"},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},xAxis:{axisTick:{show:!1},type:"category",boundaryGap:!1,data:a},yAxis:{type:"value"},series:[{type:"line",name:"上行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#f39494",areaStyle:{color:"#f39494"},lineStyle:{width:2,color:"#f39494"}}},stack:"总量",data:n},{type:"line",name:"下行",smooth:!0,showSymbol:!1,itemStyle:{normal:{color:"#9dd3e8",areaStyle:{color:"#9dd3e8"},lineStyle:{width:2,color:"#9dd3e8"}}},stack:"总量",data:i}]})}{const t=l.cpu[0],e=Math.round(l.memory.memRealUsed/l.memory.memTotal*1e3)/10,o=Math.round(l.memory.memCached/l.memory.memTotal*1e3)/10,a=Math.round(l.memory.memBuffers/l.memory.memTotal*1e3)/10,n=Math.round(l.load.one/l.load.max*100)>100?100:Math.round(l.load.one/l.load.max*100);c.setOption({title:{subtext:"单位 百分比"},tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:["CPU占用","内存占用","系统缓冲","内存缓冲","系统负载"]},yAxis:{type:"value"},series:{data:[{name:"CPU占用",value:t,itemStyle:{color:"#b3c25a"}},{name:"内存占用",value:e,itemStyle:{color:"#67b580"}},{name:"系统缓冲",value:a,itemStyle:{color:"#86ba71"}},{name:"内存缓冲",value:o,itemStyle:{color:"#feb041"}},{name:"系统负载",value:n,itemStyle:{color:"#fd7e55"}}],type:"bar",showBackground:!0,label:{show:!0,color:"#ffffff",formatter:t=>`${t.data.value} %`},backgroundStyle:{color:"rgba(180, 180, 180, 0.2)"}}})}setTimeout(t,2e3)}})}l&&s&&t()}{const t=document.querySelector("#category"),e=echarts.init(t),o=[];$(".joe_census__basic-item.category ul li").each((t,e)=>{o.push({name:e.getAttribute("data-name"),value:e.getAttribute("data-value")})}),e.setOption({tooltip:{trigger:"item"},series:[{type:"pie",roseType:"area",itemStyle:{borderRadius:8},data:o}]})}{const t=document.querySelector("#lately"),e=echarts.init(t);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"comment_lately"},success(t){e.setOption({title:{subtext:"单位 数量"},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{left:"3%",right:"3%",bottom:"3%",containLabel:!0},xAxis:{type:"category",axisTick:{show:!1},data:t.categories},yAxis:{type:"value"},series:{name:"数量",itemStyle:{normal:{color:"#91cc75",lineStyle:{width:2,color:"#91cc75"}}},data:t.series,type:"line",smooth:!0}})}})}{let t=0;function e(){"loading..."!==$(".joe_census__filing .button").html()&&$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"article_filing",page:++t},success(t){if(!t.length)return $(".joe_census__filing .item.load").remove(),Qmsg.warning("没有更多内容了");let e="";t.forEach(t=>{e+=`\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
${t.date}
\n\t\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\t\t${t.list.map(t=>`
  1. ${t.title}
  2. `).join("")}\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t`}),$("#filing").append(e),$(".joe_census__filing .button").html("加载更多")}})}e(),$(".joe_census__filing .content").on("click",".panel",function(){const t=$(this).parents(".content");t.find(".panel").not($(this)).removeClass("in"),t.find(".panel-body").not($(this).siblings(".panel-body")).stop().hide("fast"),$(this).toggleClass("in").siblings(".panel-body").stop().toggle("fast")}),$(".joe_census__filing .button").on("click",function(){e(),$(this).html("loading...")})}}); \ No newline at end of file diff --git a/census.php b/census.php index 30d5ce9..2e7ec02 100644 --- a/census.php +++ b/census.php @@ -16,7 +16,7 @@ need('public/include.php'); ?> - + @@ -86,7 +86,14 @@ options->JBTPanel && $this->options->JBTKey) : ?>
-
实时负载
+
+ 实时负载 +
+ 0 核 + / + 0 MB +
+
diff --git a/core/function.php b/core/function.php index 6bc2f06..48f5472 100644 --- a/core/function.php +++ b/core/function.php @@ -2,7 +2,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "7.1.1"; + return "7.1.2"; }; /* 判断是否是手机 */ diff --git a/package.json b/package.json index a490050..f3214b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typecho-joe-next", - "version": "7.1.1", + "version": "7.1.2", "description": "A Theme Of Typecho", "main": "index.php", "keywords": [