|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <div class="FlexContent"> |
| 4 | + <div class="LeftPart"> |
| 5 | + <div class="block" style="margin-top: 0"> |
| 6 | + <div class="quota-content"> |
| 7 | + <div class="quota-item"> |
| 8 | + <p>今日访问量</p> |
| 9 | + <p class="num">{{ todayVisit }}</p> |
| 10 | + </div> |
| 11 | + <div class="quota-item"> |
| 12 | + <p>昨日访问量</p> |
| 13 | + <p class="num">{{ yesterdayVisit }}</p> |
| 14 | + </div> |
| 15 | + <div class="quota-item"> |
| 16 | + <p>一周访问量</p> |
| 17 | + <p class="num">{{ yesterdayVisit }}</p> |
| 18 | + </div> |
| 19 | + <div class="quota-item"> |
| 20 | + <p>历史访问量</p> |
| 21 | + <p class="num">{{ allVisitNum }}</p> |
| 22 | + </div> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + <div class="block"> |
| 26 | + <div class="line-chart" id="line-chart"></div> |
| 27 | + </div> |
| 28 | + <div class="block"> |
| 29 | +<!-- <div class="block-name">分日报表</div>--> |
| 30 | + <div class="list"> |
| 31 | + <div class="list-head"> |
| 32 | + <div class="list-td">访问时间</div> |
| 33 | + <div class="list-td align">访问位置</div> |
| 34 | + <div class="list-td align">访问浏览器</div> |
| 35 | + <div class="list-td align">访问IP</div> |
| 36 | + </div> |
| 37 | + <div :class="i%2==0 ? 'list-tr single' : 'list-tr'" v-for="(item,i) in visitListData"> |
| 38 | + <div class="list-td">{{ item.time }}</div> |
| 39 | + <div class="list-td align">{{ item.location }}</div> |
| 40 | + <div class="list-td align">{{ item.browser }}</div> |
| 41 | + <div class="list-td align">{{ item.ip }}</div> |
| 42 | + </div> |
| 43 | + <div class="list-item"></div> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + <div class="RightPart"> |
| 48 | + <div class="GitPart"> |
| 49 | + <div class="TopBackBlack"></div> |
| 50 | + <div class="GitPic"> |
| 51 | + <img src="../../static/img/ZhihuIcon.jpg"> |
| 52 | + </div> |
| 53 | + <div class="GitBack"> |
| 54 | + <i class="iconfont TopBackBlackGit icon-github1"></i> |
| 55 | + </div> |
| 56 | + <div class="Content"> |
| 57 | + <div class="GitName">孙权的Github</div> |
| 58 | + <a class="BlueButton" href="https://github.com/SunQQQ" target="_blank">博客源码</a> |
| 59 | + <div class="BlogStatistic"> |
| 60 | + <div class="BlogStatisticItem"> |
| 61 | + <div class="BlogStatisticItemNum">13</div> |
| 62 | + <div class="BlogStatisticItemText AboutMeGitData">Followers</div> |
| 63 | + </div> |
| 64 | + <div class="BlogStatisticItem"> |
| 65 | + <div class="BlogStatisticItemNum">17</div> |
| 66 | + <div class="BlogStatisticItemText AboutMeGitData">Repositories</div> |
| 67 | + </div> |
| 68 | + <div class="BlogStatisticItem"> |
| 69 | + <div class="BlogStatisticItemNum">88</div> |
| 70 | + <div class="BlogStatisticItemText AboutMeGitData">Star</div> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + <div class="BigBlock AboutMeMarginTop"> |
| 76 | + <div class="TitleFontLine">Contacts</div> |
| 77 | + <div class="BlogStatistic" style="border-top: none;padding-bottom: 0"> |
| 78 | + <div class="BlogStatisticItem"> |
| 79 | + <a href="https://github.com/SunQQQ" target="_blank"><i class="iconfont icon-github AboutMeIcon" |
| 80 | + style="color:#948aec"></i></a> |
| 81 | + </div> |
| 82 | + <div class="BlogStatisticItem"> |
| 83 | + <a href="https://www.zhihu.com/people/s-q-51-44-23/activities" target="_blank"><i |
| 84 | + class="iconfont icon-zhihu AboutMeIcon" style="color:#3dbd7d"></i></a> |
| 85 | + </div> |
| 86 | + <div class="BlogStatisticItem"> |
| 87 | + <a href="https://blog.csdn.net/sun_qqq" target="_blank"><i class="iconfont icon-CN_csdnnet AboutMeIcon" |
| 88 | + style="color:#f78e3d"></i></a> |
| 89 | + </div> |
| 90 | + <div class="BlogStatisticItem"> |
| 91 | + <i class="iconfont icon-youxiang AboutMeIcon" style="color:#49a9ee"></i> |
| 92 | + </div> |
| 93 | + <div class="BlogStatisticItem"> |
| 94 | + <a href="https://music.163.com/#/user/home?id=386558098" target="_blank"><i |
| 95 | + class="iconfont AboutMeIcon icon-CN_NetEasemusic" style="color:#f46e65"></i></a> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + |
| 102 | + </div> |
| 103 | +</template> |
| 104 | + |
| 105 | +<script> |
| 106 | +import Store from "../../store"; |
| 107 | +
|
| 108 | +export default { |
| 109 | + name: "analytics", |
| 110 | + data: function () { |
| 111 | + return { |
| 112 | + todayVisit:'0', |
| 113 | + yesterdayVisit:'0', |
| 114 | + allVisitNum:'0', |
| 115 | + lineChartOption: { |
| 116 | + // title: {text: '数据趋势'}, |
| 117 | + tooltip: { |
| 118 | + trigger: 'axis' |
| 119 | + }, |
| 120 | + legend: { |
| 121 | + type: 'plain' |
| 122 | + }, |
| 123 | + xAxis: {data: []}, |
| 124 | + yAxis: {}, |
| 125 | + series: [{ |
| 126 | + name: '博客访问量(人/天)', type: 'line', data: [], |
| 127 | + itemStyle: {normal: {label: {show: true}}} |
| 128 | + }], |
| 129 | + grid:{ |
| 130 | + bottom:'20px' // 图表距离容器下方边距 |
| 131 | + } |
| 132 | + }, |
| 133 | + mapChartOption: {}, |
| 134 | + visitListData:[] |
| 135 | + } |
| 136 | + }, |
| 137 | + methods: { |
| 138 | + // 渲染折线图 |
| 139 | + setLineChart: function () { |
| 140 | + let that = this, |
| 141 | + lineChart = that.$echarts.init(document.getElementById('line-chart')); |
| 142 | + this.SQFrontAjax({ |
| 143 | + Url: '/api/visitCount/foreend', |
| 144 | + UploadData: { |
| 145 | + endTime: this.getSQTime().split(' ')[0], |
| 146 | + dayNum: 7 |
| 147 | + }, |
| 148 | + Success: function (data) { |
| 149 | + that.todayVisit = data[0].reading; |
| 150 | + that.yesterdayVisit = data[1].reading; |
| 151 | +
|
| 152 | + let dates = [], readings = []; |
| 153 | + data.forEach(function (item) { |
| 154 | + dates.push(item.time); |
| 155 | + readings.push(item.reading); |
| 156 | + }); |
| 157 | + that.lineChartOption.xAxis.data = dates.reverse(); |
| 158 | + that.lineChartOption.series[0].data = readings.reverse(); |
| 159 | + lineChart.setOption(that.lineChartOption); |
| 160 | + } |
| 161 | + }); |
| 162 | + }, |
| 163 | + setVisitList:function (){ |
| 164 | + let that = this; |
| 165 | + this.SQFrontAjax({ |
| 166 | + Url: '/api/visitRead/foreend', |
| 167 | + UploadData: {}, |
| 168 | + Success: function (data) { |
| 169 | + that.allVisitNum = data.length; |
| 170 | + data.forEach(function (item){ |
| 171 | + if(JSON.stringify(item.location) == '[]') item.location = '银河系'; |
| 172 | + if(!item.browser) item.browser = "secret"; |
| 173 | + item.ip = (item.ip).replace('::ffff:',''); |
| 174 | + }); |
| 175 | + that.visitListData = data; |
| 176 | + } |
| 177 | + }); |
| 178 | + } |
| 179 | + }, |
| 180 | + mounted: function () { |
| 181 | + Store.commit("ChangeActive", 5);// 切换Topbar高亮 |
| 182 | +
|
| 183 | + this.setLineChart(); |
| 184 | + this.setVisitList(); |
| 185 | + } |
| 186 | +} |
| 187 | +</script> |
| 188 | + |
| 189 | +<style scoped lang="less"> |
| 190 | +@import "../../static/css/base"; |
| 191 | +@import "../../static/css/AboutMe"; |
| 192 | +
|
| 193 | +.quota-content { |
| 194 | + .myflex(center); |
| 195 | + color:rgba(0, 0, 0, 0.65); |
| 196 | +} |
| 197 | +.quota-item { |
| 198 | + flex: 1; |
| 199 | + text-align: center; |
| 200 | +} |
| 201 | +.quota-item .num{ |
| 202 | + font-size:1.2rem; |
| 203 | +} |
| 204 | +.block{ |
| 205 | + background-color: #FFFFFF; |
| 206 | + margin-top: 1rem; |
| 207 | + padding: 1rem; |
| 208 | + border-radius:2px; |
| 209 | +} |
| 210 | +.block-name{ |
| 211 | + padding: 0.5rem; |
| 212 | + border-bottom: 1px solid #f0f0f0; |
| 213 | +} |
| 214 | +.line-chart { |
| 215 | + height: 300px; |
| 216 | +} |
| 217 | +.list-head{ |
| 218 | + color:#8590a6; |
| 219 | + .myflex(center); |
| 220 | + border-bottom: 1px solid #f0f0f0; |
| 221 | + padding: 8px 0; |
| 222 | +} |
| 223 | +
|
| 224 | +.list-tr{ |
| 225 | + .myflex(center); |
| 226 | + //border-bottom: 1px solid #f0f0f0; |
| 227 | + padding: 8px 0; |
| 228 | +} |
| 229 | +.list-td{ |
| 230 | + flex: 1; |
| 231 | + padding-left: 1rem; |
| 232 | +} |
| 233 | +.list .single{ |
| 234 | + background: #f6f6f6; |
| 235 | +} |
| 236 | +.list .align{ |
| 237 | + text-align: right; |
| 238 | + padding-right: 1rem; |
| 239 | +} |
| 240 | +</style> |
0 commit comments