diff --git a/assets/css/joe.census.min.css b/assets/css/joe.census.min.css index 19428d5..e86765c 100644 --- a/assets/css/joe.census.min.css +++ b/assets/css/joe.census.min.css @@ -1 +1 @@ -.joe_census__basic{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px;margin-bottom:15px}.joe_census__basic-item.list{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px}.joe_census__basic-item.list .list{display:flex;align-items:center;justify-content:space-between;background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-inner) var(--radius-wrap) var(--radius-wrap) var(--radius-inner);padding:15px 15px 12px}.joe_census__basic-item.list .list .count{display:flex;flex-direction:column;justify-content:space-between;height:100%}.joe_census__basic-item.list .list .count h6{font-size:12px;margin-bottom:10px;color:var(--seat)}.joe_census__basic-item.list .list .count p{font-size:28px;font-weight:700}.joe_census__basic-item.list .list .icon{fill:var(--classA)}.joe_census__basic-item.list .list:nth-child(1){border-left:5px solid #1cc88a;color:#1cc88a}.joe_census__basic-item.list .list:nth-child(2){border-left:5px solid #36b9cc;color:#36b9cc}.joe_census__basic-item.list .list:nth-child(3){border-left:5px solid #2196f3;color:#2196f3}.joe_census__basic-item.list .list:nth-child(4){border-left:5px solid #9c27b0;color:#9c27b0}.joe_census__basic-item.category{background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-wrap)}.joe_census__basic-item.category #category{height:230px}.joe_census__lately{background:var(--background);margin-bottom:15px;border-radius:var(--radius-wrap);box-shadow:var(--box-shadow)}.joe_census__lately .title{display:flex;align-items:center;height:45px;padding:0 12px;border-bottom:1px solid var(--classC);color:var(--main);justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_census__lately .content{padding:15px}.joe_census__lately .content #lately{height:300px}.joe_census__server{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px}.joe_census__server-item{background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-wrap)}.joe_census__server-item .title{display:flex;align-items:center;height:45px;padding:0 12px;border-bottom:1px solid var(--classC);color:var(--main);justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_census__server-item .title .count{color:var(--minor);font-size:12px}.joe_census__server-item .title .count .split{margin:0 5px}.joe_census__server-item .content{padding:15px}.joe_census__server-item .content #work,.joe_census__server-item .content #flow{height:315px} +.joe_census__basic{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px;margin-bottom:15px}.joe_census__basic-item.list{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px}.joe_census__basic-item.list .list{display:flex;align-items:center;justify-content:space-between;background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-inner) var(--radius-wrap) var(--radius-wrap) var(--radius-inner);padding:15px 15px 12px}.joe_census__basic-item.list .list .count{display:flex;flex-direction:column;justify-content:space-between;height:100%}.joe_census__basic-item.list .list .count h6{font-size:12px;margin-bottom:10px;color:var(--seat)}.joe_census__basic-item.list .list .count p{font-size:28px;font-weight:700}.joe_census__basic-item.list .list .icon{fill:var(--classA)}.joe_census__basic-item.list .list:nth-child(1){border-left:5px solid #1cc88a;color:#1cc88a}.joe_census__basic-item.list .list:nth-child(2){border-left:5px solid #36b9cc;color:#36b9cc}.joe_census__basic-item.list .list:nth-child(3){border-left:5px solid #2196f3;color:#2196f3}.joe_census__basic-item.list .list:nth-child(4){border-left:5px solid #9c27b0;color:#9c27b0}.joe_census__basic-item.category{background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-wrap)}.joe_census__basic-item.category #category{height:230px}.joe_census__lately{background:var(--background);margin-bottom:15px;border-radius:var(--radius-wrap);box-shadow:var(--box-shadow)}.joe_census__lately .title{display:flex;align-items:center;height:45px;padding:0 12px;border-bottom:1px solid var(--classC);color:var(--main);justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_census__lately .content{padding:15px}.joe_census__lately .content #lately{height:300px}.joe_census__server{display:grid;grid-template-columns:repeat(2, 1fr);gap:15px;margin-bottom:15px}.joe_census__server-item{background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-wrap)}.joe_census__server-item .title{display:flex;align-items:center;height:45px;padding:0 12px;border-bottom:1px solid var(--classC);color:var(--main);justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_census__server-item .title .count{color:var(--minor);font-size:12px}.joe_census__server-item .title .count .split{margin:0 5px}.joe_census__server-item .content{padding:15px}.joe_census__server-item .content #work,.joe_census__server-item .content #flow{height:315px}.joe_census__filing{background:var(--background);box-shadow:var(--box-shadow);border-radius:var(--radius-wrap)}.joe_census__filing .title{display:flex;align-items:center;height:45px;padding:0 12px;border-bottom:1px solid var(--classC);color:var(--main);justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_census__filing .content{padding:15px}.joe_census__filing .content .item{position:relative}.joe_census__filing .content .item:last-child .wrapper{padding-bottom:0}.joe_census__filing .content .item .head{position:absolute;top:14px;width:13px;height:13px;background:var(--classC);border-radius:50%}.joe_census__filing .content .item .tail{position:absolute;left:6px;top:0;width:1px;height:100%;background:var(--classC)}.joe_census__filing .content .item .wrapper{padding-left:30px;padding-bottom:15px}.joe_census__filing .content .item .wrapper .panel{position:relative;display:flex;align-items:center;justify-content:space-between;color:var(--routine);cursor:pointer;background:var(--classD);padding:10px;height:40px;border-radius:4px}.joe_census__filing .content .item .wrapper .panel svg{width:10px;height:10px;fill:var(--minor);-webkit-transform:rotate(180deg);transform:rotate(180deg);transition:-webkit-transform 0.25s;transition:transform 0.25s;transition:transform 0.25s, -webkit-transform 0.25s}.joe_census__filing .content .item .wrapper .panel.in svg{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.joe_census__filing .content .item .wrapper .panel::before{content:'';position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);left:-8px;width:0;height:0;border-right:8px solid var(--classD);border-top:8px solid transparent;border-bottom:8px solid transparent}.joe_census__filing .content .item .wrapper .panel-body{display:none;padding-left:20px}.joe_census__filing .content .item .wrapper .panel-body li{margin-top:20px}.joe_census__filing .content .item .wrapper .panel-body li a{color:var(--routine)}.joe_census__filing .content .item .wrapper .panel-body li a:hover{color:var(--theme)}.joe_census__filing .content .item.load{padding-top:15px}.joe_census__filing .content .item.load .head{top:25px;background:#2db7f5}.joe_census__filing .content .item.load .button{position:relative;margin-left:30px;border:none;background:#2db7f5;color:#fff;border-radius:4px;padding:0 12px;height:34px;font-size:13px}.joe_census__filing .content .item.load .button::before{content:'';position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);left:-8px;width:0;height:0;border-right:8px solid #2db7f5;border-top:8px solid transparent;border-bottom:8px solid transparent} diff --git a/assets/css/joe.census.min.scss b/assets/css/joe.census.min.scss index 17ae9fc..201d89c 100644 --- a/assets/css/joe.census.min.scss +++ b/assets/css/joe.census.min.scss @@ -89,6 +89,7 @@ display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; + margin-bottom: 15px; &-item { background: var(--background); box-shadow: var(--box-shadow); @@ -119,4 +120,129 @@ } } } + &__filing { + background: var(--background); + box-shadow: var(--box-shadow); + border-radius: var(--radius-wrap); + .title { + display: flex; + align-items: center; + height: 45px; + padding: 0 12px; + border-bottom: 1px solid var(--classC); + color: var(--main); + justify-content: space-between; + user-select: none; + } + .content { + padding: 15px; + .item { + position: relative; + &:last-child { + .wrapper { + padding-bottom: 0; + } + } + .head { + position: absolute; + top: 14px; + width: 13px; + height: 13px; + background: var(--classC); + border-radius: 50%; + } + .tail { + position: absolute; + left: 6px; + top: 0; + width: 1px; + height: 100%; + background: var(--classC); + } + .wrapper { + padding-left: 30px; + padding-bottom: 15px; + .panel { + position: relative; + display: flex; + align-items: center; + justify-content: space-between; + color: var(--routine); + cursor: pointer; + background: var(--classD); + padding: 10px; + height: 40px; + border-radius: 4px; + svg { + width: 10px; + height: 10px; + fill: var(--minor); + transform: rotate(180deg); + transition: transform 0.25s; + } + &.in { + svg { + transform: rotate(90deg); + } + } + &::before { + content: ''; + position: absolute; + top: 50%; + transform: translateY(-50%); + left: -8px; + width: 0; + height: 0; + border-right: 8px solid var(--classD); + border-top: 8px solid transparent; + border-bottom: 8px solid transparent; + } + } + .panel-body { + display: none; + padding-left: 20px; + li { + margin-top: 20px; + a { + color: var(--routine); + &:hover { + color: var(--theme); + } + } + } + } + } + &.load { + padding-top: 15px; + .head { + top: 25px; + background: #2db7f5; + } + .button { + position: relative; + margin-left: 30px; + border: none; + background: #2db7f5; + color: #fff; + border-radius: 4px; + padding: 0 12px; + height: 34px; + font-size: 13px; + &::before { + content: ''; + position: absolute; + top: 50%; + transform: translateY(-50%); + left: -8px; + width: 0; + height: 0; + border-right: 8px solid #2db7f5; + border-top: 8px solid transparent; + border-bottom: 8px solid transparent; + } + } + } + } + } + } } diff --git a/assets/js/joe.census.js b/assets/js/joe.census.js index 9dacf9f..c7cda0d 100644 --- a/assets/js/joe.census.js +++ b/assets/js/joe.census.js @@ -2,22 +2,20 @@ document.addEventListener('DOMContentLoaded', () => { { /* 转换字节 */ const bytesToSize = bytes => { + if (!bytes) return '0 B'; const k = 1024, sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], i = Math.floor(Math.log(bytes) / Math.log(k)); return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; }; - const categories = []; const upSeries = []; const downSeries = []; - const flowDom = document.querySelector('#flow'); const workDom = document.querySelector('#work'); const flowChart = flowDom && echarts.init(flowDom); const workChart = workDom && echarts.init(workDom); if (flowDom && workDom) initChart(); - function initChart() { $.ajax({ url: Joe.BASE_API, @@ -27,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => { routeType: 'server_status' }, success(res) { + if (!res.status) Qmsg.warning('服务器接口异常!'); { $('.joe_census__server-item .count .up').html(`总发送:${bytesToSize(res.upTotal)}`); $('.joe_census__server-item .count .down').html(`总接收:${bytesToSize(res.downTotal)}`); @@ -48,7 +47,7 @@ document.addEventListener('DOMContentLoaded', () => { grid: { left: '3%', right: '4%', - bottom: '0', + bottom: '3%', containLabel: true }, tooltip: { @@ -250,6 +249,9 @@ document.addEventListener('DOMContentLoaded', () => { }, success(res) { latelyChart.setOption({ + title: { + subtext: '单位 数量' + }, tooltip: { trigger: 'axis', axisPointer: { @@ -294,4 +296,55 @@ document.addEventListener('DOMContentLoaded', () => { } }); } + + /* 初始化归档 */ + { + let page = 0; + initFiling(); + function initFiling() { + if ($('.joe_census__filing .button').html() === 'loading...') return; + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { + routeType: 'article_filing', + page: ++page + }, + success(res) { + if (!res.length) { + $('.joe_census__filing .item.load').remove(); + return Qmsg.warning('没有更多内容了'); + } + let htmlStr = ''; + res.forEach(item => { + htmlStr += ` +
+
+
+
+
${item.date}
+
    + ${item.list.map(_ => `
  1. ${_.title}
  2. `).join('')} +
+
+
+ `; + }); + $('#filing').append(htmlStr); + $('.joe_census__filing .button').html('加载更多'); + } + }); + } + $('.joe_census__filing .content').on('click', '.panel', function () { + const panelBox = $(this).parents('.content'); + panelBox.find('.panel').not($(this)).removeClass('in'); + panelBox.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 () { + initFiling(); + $(this).html('loading...'); + }); + } }); diff --git a/assets/js/joe.census.min.js b/assets/js/joe.census.min.js index 9b8525f..97be38f 100644 --- a/assets/js/joe.census.min.js +++ b/assets/js/joe.census.min.js @@ -1 +1 @@ -document.addEventListener("DOMContentLoaded",()=>{{const t=e=>{const t=1024,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(e)/Math.log(t));return(e/Math.pow(t,a)).toPrecision(3)+" "+o[a]},o=[],a=[],r=[],l=document.querySelector("#flow"),i=document.querySelector("#work"),s=l&&echarts.init(l),n=i&&echarts.init(i);function e(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"server_status"},success(l){{$(".joe_census__server-item .count .up").html(`总发送:${t(l.upTotal)}`),$(".joe_census__server-item .count .down").html(`总接收:${t(l.downTotal)}`);const e=new Date,i=String(e.getHours()).padStart(2,0),n=String(e.getMinutes()).padStart(2,0),c=String(e.getSeconds()).padStart(2,0),m=`${i}:${n}:${c}`;o.push(m),a.push(l.up),r.push(l.down),o.length>5&&o.shift(),a.length>5&&a.shift(),r.length>5&&r.shift(),s.setOption({title:{subtext:"单位 KB/s"},grid:{left:"3%",right:"4%",bottom:"0",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:r}]})}{const e=l.cpu[0],t=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,r=Math.round(l.load.one/l.load.max*100)>100?100:Math.round(l.load.one/l.load.max*100);n.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:e,itemStyle:{color:"#b3c25a"}},{name:"内存占用",value:t,itemStyle:{color:"#67b580"}},{name:"系统缓冲",value:a,itemStyle:{color:"#86ba71"}},{name:"内存缓冲",value:o,itemStyle:{color:"#feb041"}},{name:"系统负载",value:r,itemStyle:{color:"#fd7e55"}}],type:"bar",showBackground:!0,label:{show:!0,color:"#ffffff",formatter:e=>`${e.data.value} %`},backgroundStyle:{color:"rgba(180, 180, 180, 0.2)"}}})}setTimeout(e,2e3)}})}l&&i&&e()}{const e=document.querySelector("#category"),t=echarts.init(e),o=[];$(".joe_census__basic-item.category ul li").each((e,t)=>{o.push({name:t.getAttribute("data-name"),value:t.getAttribute("data-value")})}),t.setOption({tooltip:{trigger:"item"},series:[{type:"pie",roseType:"area",itemStyle:{borderRadius:8},data:o}]})}{const e=document.querySelector("#lately"),t=echarts.init(e);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"comment_lately"},success(e){t.setOption({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:e.categories},yAxis:{type:"value"},series:{name:"数量",itemStyle:{normal:{color:"#91cc75",lineStyle:{width:2,color:"#91cc75"}}},data:e.series,type:"line",smooth:!0}})}})}}); \ No newline at end of file +document.addEventListener("DOMContentLoaded",()=>{{const e=t=>{if(!t)return"0 B";const e=1024,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 diff --git a/census.php b/census.php index 13e664f..0af2ec2 100644 --- a/census.php +++ b/census.php @@ -14,9 +14,9 @@ need('public/include.php'); ?> - + - + @@ -106,6 +106,17 @@ +
+
文章归档
+
+
+
+
+
+ +
+
+
need('public/footer.php'); ?> diff --git a/core/function.php b/core/function.php index 113f43a..b1aae0b 100644 --- a/core/function.php +++ b/core/function.php @@ -2,7 +2,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "7.0.7"; + return "7.0.8"; }; /* 判断是否是手机 */ diff --git a/core/route.php b/core/route.php index bb89e21..d5f0e77 100644 --- a/core/route.php +++ b/core/route.php @@ -294,6 +294,7 @@ function _getHuyaList($self) } } +/* 获取服务器状态 */ function _getServerStatus($self) { header("HTTP/1.1 200 OK"); @@ -325,6 +326,8 @@ function _getServerStatus($self) $response = json_decode(curl_exec($ch), true); curl_close($ch); $self->response->throwJson(array( + /* 状态 */ + "status" => $response ? true : false, /* 上行流量KB */ "up" => $response["up"] ? $response["up"] : 0, /* 下行流量KB */ @@ -342,6 +345,7 @@ function _getServerStatus($self) )); } +/* 获取最近评论 */ function _getCommentLately($self) { header("HTTP/1.1 200 OK"); @@ -368,5 +372,37 @@ function _getCommentLately($self) function _getArticleFiling($self) { - + header("HTTP/1.1 200 OK"); + header('Access-Control-Allow-Origin:*'); + header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept"); + $page = $self->request->page; + $pageSize = 8; + if (!preg_match('/^\d+$/', $page)) return $self->response->throwJson(array("data" => "非法请求!已屏蔽!")); + if ($page == 0) $page = 1; + $offset = $pageSize * ($page - 1); + $time = time(); + $db = Typecho_Db::get(); + $prefix = $db->getPrefix(); + $result = []; + $sql = "SELECT FROM_UNIXTIME(created, '%Y 年 %m 月') as date FROM `{$prefix}contents` WHERE created < {$time} AND (password is NULL or password = '') AND status = 'publish' AND type = 'post' GROUP BY FROM_UNIXTIME(created, '%Y 年 %m 月') DESC LIMIT {$pageSize} OFFSET {$offset}"; + $temp = $db->fetchAll($sql); + $options = Typecho_Widget::widget('Widget_Options'); + foreach ($temp as $item) { + $date = $item['date']; + $list = []; + $sql = "SELECT * FROM `{$prefix}contents` WHERE created < {$time} AND (password is NULL or password = '') AND status = 'publish' AND type = 'post' AND FROM_UNIXTIME(created, '%Y 年 %m 月') = '{$date}' ORDER BY created DESC"; + $_list = $db->fetchAll($sql); + foreach ($_list as $_item) { + $type = $_item['type']; + $routeExists = (NULL != Typecho_Router::get($type)); + $_item['pathinfo'] = $routeExists ? Typecho_Router::url($type, $_item) : '#'; + $_item['permalink'] = Typecho_Common::url($_item['pathinfo'], $options->index); + $list[] = array( + "title" => date('m/d', $_item['created']) . ':' . $_item['title'], + "permalink" => $_item['permalink'], + ); + } + $result[] = array("date" => $date, "list" => $list); + } + $self->response->throwJson($result); } diff --git a/core/widget.php b/core/widget.php index c145e24..6281baa 100644 --- a/core/widget.php +++ b/core/widget.php @@ -56,4 +56,4 @@ class Widget_Contents_Post extends Widget_Abstract_Contents array($this, 'push') ); } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 386a5a1..e491bbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typecho-joe-next", - "version": "7.0.7", + "version": "7.0.8", "description": "A Theme Of Typecho", "main": "index.php", "keywords": [ diff --git a/public/header.php b/public/header.php index 039a284..e0ac923 100644 --- a/public/header.php +++ b/public/header.php @@ -199,15 +199,15 @@ diff --git a/public/include.php b/public/include.php index d9ca92d..7aa30b7 100644 --- a/public/include.php +++ b/public/include.php @@ -19,7 +19,7 @@ - +