Skip to content

Commit a3a331b

Browse files
committed
add dashboard
1 parent 33e384e commit a3a331b

File tree

9 files changed

+67
-59
lines changed

9 files changed

+67
-59
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"vue-router": "2.3.0",
3232
"vuedraggable": "2.8.4",
3333
"vuex": "2.2.1",
34-
"xlsx": "0.8.1"
34+
"xlsx": "0.8.1",
35+
"vue-count-to":"1.0.5"
3536
},
3637
"devDependencies": {
3738
"autoprefixer": "6.7.2",

src/api/article.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
import fetch, { tpFetch } from 'utils/fetch';
2-
import { param } from 'utils';
1+
import { tpFetch } from 'utils/fetch';
32

4-
export function getList(query) {
3+
export function getList() {
54
return tpFetch({
65
url: '/article/list',
76
method: 'get'
87
});
98
}
10-
export function upload(data) {
11-
return tpFetch({
12-
url: 'https://upload.qbox.me',
13-
method: 'post',
14-
data
15-
});
16-
}
17-
18-
19-
/* 外部uri转七牛uri*/
20-
export function netUpload(token, net_url) {
21-
const imgData = {
22-
net_url
23-
};
24-
return fetch({
25-
url: '/qiniu/upload/net/async',
26-
method: 'post',
27-
data: imgData
28-
});
29-
}

src/components/Charts/barPercent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
methods: {
4949
initBar() {
5050
this.chart = echarts.init(document.getElementById(this.id));
51+
this.setOptions();
5152
},
5253
setOptions() {
5354
this.chart.setOption({

src/components/Charts/line.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
},
4747
mounted() {
4848
this.chart = echarts.init(document.getElementById(this.id));
49+
this.setLine(this.listData);
4950
},
5051
methods: {
5152
setLine(dataList) {

src/mock/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const articleList = {
77
'data|20': [{
88
id: '@id',
99
title: '@ctitle(10, 20)',
10+
'status|1': ['published', 'draft'],
1011
author: '@cname',
1112
display_time: '@datetime',
1213
pageviews: '@integer(300, 5000)'

src/router/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import sendPWD from '../views/login/sendpwd';
1919
import reset from '../views/login/reset';
2020

2121
/* components*/
22+
const componentsIndex = resolve => require(['../views/components/index'], resolve);
2223
const Tinymce = resolve => require(['../views/components/tinymce'], resolve);
2324
const Markdown = resolve => require(['../views/components/markdown'], resolve);
2425
const JsonEditor = resolve => require(['../views/components/jsoneditor'], resolve);
@@ -32,6 +33,7 @@ const Mixin = resolve => require(['../views/components/mixin'], resolve);
3233

3334

3435
/* charts*/
36+
const chartIndex = resolve => require(['../views/charts/index'], resolve);
3537
const KeyboardChart = resolve => require(['../views/charts/keyboard'], resolve);
3638
const KeyboardChart2 = resolve => require(['../views/charts/keyboard2'], resolve);
3739
const LineMarker = resolve => require(['../views/charts/line'], resolve);
@@ -80,10 +82,11 @@ export default new Router({
8082
{
8183
path: '/components',
8284
component: Layout,
83-
redirect: 'noredirect',
85+
redirect: '/components/index',
8486
name: '组件',
8587
icon: 'zujian',
8688
children: [
89+
{ path: 'index', component: componentsIndex, name: '介绍' },
8790
{ path: 'tinymce', component: Tinymce, name: '富文本编辑器' },
8891
{ path: 'markdown', component: Markdown, name: 'Markdown' },
8992
{ path: 'jsoneditor', component: JsonEditor, name: 'JSON编辑器' },
@@ -99,10 +102,11 @@ export default new Router({
99102
{
100103
path: '/charts',
101104
component: Layout,
102-
redirect: 'noredirect',
105+
redirect: '/charts/index',
103106
name: '图表',
104107
icon: 'tubiaoleixingzhengchang',
105108
children: [
109+
{ path: 'index', component: chartIndex, name: '介绍' },
106110
{ path: 'keyboard', component: KeyboardChart, name: '键盘图表' },
107111
{ path: 'keyboard2', component: KeyboardChart2, name: '键盘图表2' },
108112
{ path: 'line', component: LineMarker, name: '折线图' },

src/views/charts/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="components-container" >
3+
介绍
4+
</div>
5+
</template>

src/views/components/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="components-container" >
3+
介绍
4+
</div>
5+
</template>

src/views/dashboard/editor/index.vue

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@
77
<div class="info-container">
88
<span class="display_name">{{name}}</span>
99
<div class="info-wrapper">
10-
<router-link class="info-item" :to="'/article/wscnlist?uid='+uid">
11-
<span class="info-item-num">{{statisticsData.article_count | toThousandslsFilter}}</span>
10+
<div class="info-item" :to="'/article/wscnlist?uid='+uid">
11+
<countTo class="info-item-num" :startVal='0' :endVal='statisticsData.article_count' :duration='3400'></countTo>
1212
<span class="info-item-text">文章</span>
1313
<wscn-icon-svg icon-class="a" class="dashboard-editor-icon"/>
14-
</router-link>
14+
</div>
1515
<div class="info-item" style="cursor: auto">
16-
<span class="info-item-num"> {{statisticsData.pageviews_count | toThousandslsFilter}}</span>
16+
<countTo class="info-item-num" :startVal='0' :endVal='statisticsData.pageviews_count' :duration='3600'></countTo>
1717
<span class="info-item-text">浏览量</span>
1818
<wscn-icon-svg icon-class="b" class="dashboard-editor-icon"/>
1919
</div>
20-
<router-link class="info-item" :to="'/comment/commentslist?res_author_id='+uid">
21-
<span class="info-item-num">{{statisticsData.comment_count | toThousandslsFilter}}</span>
20+
<div class="info-item" :to="'/comment/commentslist?res_author_id='+uid">
21+
<countTo class="info-item-num" ref='countTo3' :startVal='0' :endVal='statisticsData.comment_count' :duration='3800'></countTo>
2222
<span class="info-item-text">评论</span>
2323
<wscn-icon-svg icon-class="c" class="dashboard-editor-icon"/>
24-
</router-link>
24+
</div>
2525
</div>
2626
</div>
2727
</div>
2828

2929
<div class="btn-group">
30-
<router-link class="pan-btn blue-btn" to="/article/create">发表文章</router-link>
31-
<router-link class="pan-btn light-blue-btn" to="/livenews/create">发布快讯</router-link>
32-
<router-link class="pan-btn red-btn" to="/push/create">推送</router-link>
33-
<router-link class="pan-btn pink-btn" to="/comment/commentslist">评论管理</router-link>
34-
<router-link class="pan-btn green-btn" to="/article/wscnlist">文章列表</router-link>
35-
<router-link class="pan-btn tiffany-btn" to="/livenews/list">实时列表</router-link>
30+
<router-link class="pan-btn blue-btn" to="/components/index">组价</router-link>
31+
<router-link class="pan-btn light-blue-btn" to="/charts/index">图表</router-link>
32+
<router-link class="pan-btn red-btn" to="/errorpage/404">错误页面</router-link>
33+
<router-link class="pan-btn pink-btn" to="/errlog/log">错误日志</router-link>
34+
<router-link class="pan-btn green-btn" to="/article/wscnlist">导出excel</router-link>
35+
<router-link class="pan-btn tiffany-btn" to="/excel/download">实时列表</router-link>
3636
</div>
3737

3838
<div class="clearfix main-dashboard-container">
@@ -47,20 +47,17 @@
4747
<template v-if="recentArticles.length!=0">
4848
<div class="recent-articles-item" v-for="item in recentArticles">
4949
<span class="recent-articles-status">{{item.status | statusFilter}}</span>
50-
<router-link class="recent-articles-content" :to="'/article/edit/'+item.id">
51-
<span>{{item.title}}</span>
52-
</router-link>
53-
<span class="recent-articles-time"><i style="padding-right: 4px;" class="el-icon-time"></i>{{item.display_time | parseTime('{m}-{d} {h}:{i}')}}</span>
50+
<span class="recent-articles-content" :to="'/article/edit/'+item.id">
51+
{{item.title}}
52+
</span>
53+
<span class="recent-articles-time">{{item.author}}</span>
5454
</div>
5555
</template>
5656
<template v-else>
5757
<div class="recent-articles-emptyTitle">你太懒了最近都没有撸</div>
5858
<!--<img class="emptyGif" :src="emptyGif">-->
5959
</template>
6060
</div>
61-
<router-link class="recent-articles-more" :to="'/article/wscnlist?uid='+uid">
62-
Show more
63-
</router-link>
6461
</div>
6562
</div>
6663
</div>
@@ -71,23 +68,37 @@
7168
import PanThumb from 'components/PanThumb';
7269
import MonthKpi from './monthKpi';
7370
import ArticlesChart from './articlesChart';
74-
// import { getStatistics } from 'api/article';
75-
71+
import { getList } from 'api/article';
7672
import emptyGif from 'assets/compbig.gif';
73+
import countTo from 'vue-count-to';
7774
export default {
7875
name: 'dashboard-editor',
79-
components: { PanThumb, MonthKpi, ArticlesChart },
76+
components: { PanThumb, MonthKpi, ArticlesChart, countTo },
8077
data() {
8178
return {
8279
chart: null,
8380
statisticsData: {
84-
article_count: undefined,
85-
comment_count: undefined,
81+
article_count: 1024,
82+
comment_count: 102400,
8683
latest_article: [],
87-
month_article_count: undefined,
88-
pageviews_count: undefined,
89-
week_article: []
84+
month_article_count: 28,
85+
pageviews_count: 1024,
86+
week_article: [
87+
{ count: 30, week: '201716' },
88+
{ count: 26, week: '201715' },
89+
{ count: 31, week: '201714' },
90+
{ count: 28, week: '201713' },
91+
{ count: 40, week: '201712' },
92+
{ count: 41, week: '201711' },
93+
{ count: 50, week: '201710' },
94+
{ count: 42, week: '201709' },
95+
{ count: 36, week: '201708' },
96+
{ count: 32, week: '201707' },
97+
{ count: 40, week: '201706' },
98+
{ count: 41, week: '201705' }
99+
]
90100
},
101+
list: [],
91102
emptyGif
92103
}
93104
},
@@ -104,15 +115,15 @@
104115
'roles'
105116
]),
106117
recentArticles() {
107-
return this.statisticsData.latest_article.slice(0, 7)
118+
return this.list.slice(0, 7)
108119
}
109120
},
110121
methods: {
111122
fetchData() {
112-
// getStatistics().then(response => {
113-
// this.statisticsData = response.data;
114-
// this.statisticsData.week_article = this.statisticsData.week_article.slice().reverse();
115-
// })
123+
getList(this.listQuery).then(response => {
124+
console.log(response.data)
125+
this.list = response.data;
126+
})
116127
}
117128
},
118129
filters: {

0 commit comments

Comments
 (0)