|
@@ -5,10 +5,10 @@
|
|
|
<el-col :span="24" class="top">
|
|
|
<top topType="2" :leftArrow="false"></top>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
|
|
|
- <lineBar title="发表数"></lineBar>
|
|
|
- <gauge title="阅读数"></gauge>
|
|
|
- <pie title="点赞数"></pie>
|
|
|
+ <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }" v-if="display">
|
|
|
+ <lineBar title="发表数" :x="chartsLineX" :data="chartsArticle"></lineBar>
|
|
|
+ <gauge title="阅读数" :data="chartsRead"></gauge>
|
|
|
+ <!-- <pie title="点赞数"></pie> -->
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="foot">
|
|
|
<foot></foot>
|
|
@@ -26,6 +26,7 @@ import top from '@/layout/common/top.vue';
|
|
|
import foot from '@/layout/common/foot.vue';
|
|
|
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: count } = createNamespacedHelpers('count');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
@@ -33,22 +34,71 @@ export default {
|
|
|
top,
|
|
|
foot,
|
|
|
lineBar,
|
|
|
- pie,
|
|
|
+ // pie,
|
|
|
gauge,
|
|
|
},
|
|
|
data: function() {
|
|
|
return {
|
|
|
+ display: false,
|
|
|
clientHeight: '',
|
|
|
+ articles: {},
|
|
|
+ reads: {},
|
|
|
+ word: { refute: '文章', serve: '服务', topic: '话题' },
|
|
|
+ data: [
|
|
|
+ [1, 2, 3, 4, 5, 6, 7],
|
|
|
+ [8, 9, 10, 11, 12, 13, 14],
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
mounted() {
|
|
|
let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 90;
|
|
|
this.$set(this, `clientHeight`, clientHeight);
|
|
|
},
|
|
|
- methods: {},
|
|
|
+ methods: {
|
|
|
+ ...count(['index']),
|
|
|
+ async init() {
|
|
|
+ const res = await this.index();
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const keys = Object.keys(res.data);
|
|
|
+ for (const key of keys) {
|
|
|
+ this.$set(this, key, res.data[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.display = true;
|
|
|
+ },
|
|
|
+ },
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
+ chartsRead() {
|
|
|
+ let arr = [];
|
|
|
+ const keys = Object.keys(this.reads);
|
|
|
+ for (const key of keys) {
|
|
|
+ const name = this.word[key];
|
|
|
+ arr.push({ name, value: this.reads[key] });
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
+ chartsArticle() {
|
|
|
+ let arr = [];
|
|
|
+ // 根据this.word来决定取值的顺序
|
|
|
+ let keys = Object.keys(this.word);
|
|
|
+ for (const key of keys) {
|
|
|
+ const items = this.articles[key];
|
|
|
+ const marr = items.map(i => i.sum);
|
|
|
+ arr.push(marr);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
+ chartsLineX() {
|
|
|
+ let arr = [];
|
|
|
+ const keys = Object.keys(this.articles);
|
|
|
+ const obj = this.articles[keys[0]];
|
|
|
+ if (obj) arr = obj.map(i => i.date);
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
},
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|