mirror of https://github.com/halo-dev/halo
refactor: user profile.
parent
61df292126
commit
f376635340
|
@ -2826,9 +2826,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
||||
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
|
||||
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.10",
|
||||
"is-buffer": "^2.0.2"
|
||||
|
@ -6700,9 +6700,9 @@
|
|||
}
|
||||
},
|
||||
"filepond": {
|
||||
"version": "4.8.2",
|
||||
"resolved": "https://registry.npmjs.org/filepond/-/filepond-4.8.2.tgz",
|
||||
"integrity": "sha512-CWXCv3amz1ECVidA33vezuXqfBI0O+UKWGh3g4574ZbyLwSwcJEbOy0vv2kgE0Xdg39xDQAruxHUGZm/xYK2oA=="
|
||||
"version": "4.9.2",
|
||||
"resolved": "https://registry.npmjs.org/filepond/-/filepond-4.9.2.tgz",
|
||||
"integrity": "sha512-YJGwIPFnkHxtG88LLpSuZSCySaxRDOKqSKywQ7KgPCRoUzHD8e5uC8Ii78+mjfBaU5QDOND/FFQLXLoLE99oJw=="
|
||||
},
|
||||
"filepond-plugin-image-preview": {
|
||||
"version": "4.5.0",
|
||||
|
@ -10276,9 +10276,9 @@
|
|||
}
|
||||
},
|
||||
"marked": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz",
|
||||
"integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg=="
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.8.0.tgz",
|
||||
"integrity": "sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ=="
|
||||
},
|
||||
"md5.js": {
|
||||
"version": "1.3.5",
|
||||
|
@ -14521,9 +14521,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"vue": {
|
||||
"version": "2.6.10",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.10.tgz",
|
||||
"integrity": "sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ=="
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz",
|
||||
"integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ=="
|
||||
},
|
||||
"vue-clipboard2": {
|
||||
"version": "0.3.1",
|
||||
|
@ -14713,9 +14713,9 @@
|
|||
}
|
||||
},
|
||||
"vue-template-compiler": {
|
||||
"version": "2.6.10",
|
||||
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.10.tgz",
|
||||
"integrity": "sha512-jVZkw4/I/HT5ZMvRnhv78okGusqe0+qH2A0Em0Cp8aq78+NK9TII263CDVz2QXZsIT+yyV/gZc/j/vlwa+Epyg==",
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz",
|
||||
"integrity": "sha512-KIq15bvQDrcCjpGjrAhx4mUlyyHfdmTaoNfeoATHLAiWB+MU3cx4lOzMwrnUh9cCxy0Lt1T11hAFY6TQgroUAA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"de-indent": "^1.0.2",
|
||||
|
|
10
package.json
10
package.json
|
@ -11,15 +11,15 @@
|
|||
"dependencies": {
|
||||
"animate.css": "^3.7.0",
|
||||
"ant-design-vue": "^1.4.10",
|
||||
"axios": "^0.18.0",
|
||||
"axios": "^0.19.0",
|
||||
"enquire.js": "^2.1.6",
|
||||
"filepond": "^4.7.2",
|
||||
"filepond": "^4.9.2",
|
||||
"filepond-plugin-image-preview": "^4.5.0",
|
||||
"halo-editor": "^2.8.2",
|
||||
"marked": "^0.7.0",
|
||||
"marked": "^0.8.0",
|
||||
"moment": "^2.24.0",
|
||||
"verte": "^0.0.12",
|
||||
"vue": "^2.6.10",
|
||||
"vue": "^2.6.11",
|
||||
"vue-clipboard2": "^0.3.0",
|
||||
"vue-codemirror-lite": "^1.0.4",
|
||||
"vue-count-to": "^1.0.13",
|
||||
|
@ -50,7 +50,7 @@
|
|||
"less": "^3.10.0",
|
||||
"less-loader": "^5.0.0",
|
||||
"vue-svg-icon-loader": "^2.1.1",
|
||||
"vue-template-compiler": "^2.6.10"
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import service from '@/utils/service'
|
||||
|
||||
const baseUrl = '/api/admin/statistics'
|
||||
|
||||
const statisticsApi = {}
|
||||
|
||||
statisticsApi.statistics = () => {
|
||||
return service({
|
||||
url: `${baseUrl}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
statisticsApi.statisticsWithUser = () => {
|
||||
return service({
|
||||
url: `${baseUrl}/user`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default statisticsApi
|
|
@ -12,7 +12,7 @@
|
|||
<analysis-card
|
||||
:loading="countsLoading"
|
||||
title="文章"
|
||||
:number="countsData.postCount"
|
||||
:number="statisticsData.postCount"
|
||||
>
|
||||
<router-link
|
||||
:to="{ name:'PostList' }"
|
||||
|
@ -33,7 +33,7 @@
|
|||
<analysis-card
|
||||
:loading="countsLoading"
|
||||
title="评论"
|
||||
:number="countsData.commentCount"
|
||||
:number="statisticsData.commentCount"
|
||||
>
|
||||
<router-link
|
||||
:to="{ name:'Comments' }"
|
||||
|
@ -54,14 +54,14 @@
|
|||
<analysis-card
|
||||
:loading="countsLoading"
|
||||
title="总访问"
|
||||
:number="countsData.visitCount"
|
||||
:number="statisticsData.visitCount"
|
||||
>
|
||||
<a-tooltip slot="action">
|
||||
<template slot="title">
|
||||
文章总访问共
|
||||
<countTo
|
||||
:startVal="0"
|
||||
:endVal="countsData.visitCount"
|
||||
:endVal="statisticsData.visitCount"
|
||||
:duration="3000"
|
||||
></countTo>次
|
||||
</template>
|
||||
|
@ -82,10 +82,10 @@
|
|||
<analysis-card
|
||||
:loading="countsLoading"
|
||||
title="建立天数"
|
||||
:number="countsData.establishDays"
|
||||
:number="statisticsData.establishDays"
|
||||
>
|
||||
<a-tooltip slot="action">
|
||||
<template slot="title">博客建立于 {{ countsData.birthday | moment }}</template>
|
||||
<template slot="title">博客建立于 {{ statisticsData.birthday | moment }}</template>
|
||||
<a href="javascript:void(0);">
|
||||
<a-icon type="info-circle-o" />
|
||||
</a>
|
||||
|
@ -336,7 +336,7 @@ import countTo from 'vue-count-to'
|
|||
|
||||
import postApi from '@/api/post'
|
||||
import logApi from '@/api/log'
|
||||
import adminApi from '@/api/admin'
|
||||
import statisticsApi from '@/api/statistics'
|
||||
import journalApi from '@/api/journal'
|
||||
export default {
|
||||
name: 'Dashboard',
|
||||
|
@ -359,7 +359,7 @@ export default {
|
|||
logDrawerVisible: false,
|
||||
postData: [],
|
||||
logData: [],
|
||||
countsData: {},
|
||||
statisticsData: {},
|
||||
journal: {
|
||||
content: '',
|
||||
photos: []
|
||||
|
@ -379,7 +379,7 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.getCounts()
|
||||
this.getStatistics()
|
||||
this.listLatestPosts()
|
||||
this.listLatestLogs()
|
||||
},
|
||||
|
@ -413,7 +413,7 @@ export default {
|
|||
beforeRouteEnter(to, from, next) {
|
||||
next(vm => {
|
||||
vm.interval = setInterval(() => {
|
||||
vm.getCounts()
|
||||
vm.getStatistics()
|
||||
}, 5000)
|
||||
})
|
||||
},
|
||||
|
@ -442,9 +442,9 @@ export default {
|
|||
this.writeLoading = false
|
||||
})
|
||||
},
|
||||
getCounts() {
|
||||
adminApi.counts().then(response => {
|
||||
this.countsData = response.data.data
|
||||
getStatistics() {
|
||||
statisticsApi.statistics().then(response => {
|
||||
this.statisticsData = response.data.data
|
||||
this.countsLoading = false
|
||||
})
|
||||
},
|
||||
|
|
|
@ -40,20 +40,21 @@
|
|||
<a-icon type="mail" />{{ user.email }}
|
||||
</p>
|
||||
<p>
|
||||
<a-icon type="calendar" />{{ counts.establishDays || 0 }} 天
|
||||
<a-icon type="calendar" />{{ statistics.establishDays || 0 }} 天
|
||||
</p>
|
||||
</div>
|
||||
<a-divider />
|
||||
<div class="general-profile">
|
||||
<a-list
|
||||
:loading="countsLoading"
|
||||
:loading="statisticsLoading"
|
||||
itemLayout="horizontal"
|
||||
>
|
||||
<a-list-item>累计发表了 {{ counts.postCount || 0 }} 篇文章。</a-list-item>
|
||||
<a-list-item>累计创建了 {{ counts.attachmentCount || 0 }} 个附件。</a-list-item>
|
||||
<a-list-item>累计获得了 {{ counts.commentCount || 0 }} 条评论。</a-list-item>
|
||||
<a-list-item>累计添加了 {{ counts.linkCount || 0 }} 个友链。</a-list-item>
|
||||
<a-list-item>文章总访问 {{ counts.visitCount || 0 }} 次。</a-list-item>
|
||||
<a-list-item>累计发表了 {{ statistics.postCount || 0 }} 篇文章。</a-list-item>
|
||||
<a-list-item>累计创建了 {{ statistics.categoryCount || 0 }} 个分类。</a-list-item>
|
||||
<a-list-item>累计创建了 {{ statistics.tagCount || 0 }} 个标签。</a-list-item>
|
||||
<a-list-item>累计获得了 {{ statistics.commentCount || 0 }} 条评论。</a-list-item>
|
||||
<a-list-item>累计添加了 {{ statistics.linkCount || 0 }} 个友链。</a-list-item>
|
||||
<a-list-item>文章总访问 {{ statistics.visitCount || 0 }} 次。</a-list-item>
|
||||
<a-list-item></a-list-item>
|
||||
</a-list>
|
||||
</div>
|
||||
|
@ -142,7 +143,7 @@
|
|||
<script>
|
||||
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
|
||||
import userApi from '@/api/user'
|
||||
import adminApi from '@/api/admin'
|
||||
import statisticsApi from '@/api/statistics'
|
||||
import { mapMutations, mapGetters } from 'vuex'
|
||||
import MD5 from 'md5.js'
|
||||
|
||||
|
@ -152,10 +153,10 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
countsLoading: true,
|
||||
statisticsLoading: true,
|
||||
attachmentDrawerVisible: false,
|
||||
user: {},
|
||||
counts: {},
|
||||
statistics: {},
|
||||
passwordParam: {
|
||||
oldPassword: null,
|
||||
newPassword: null,
|
||||
|
@ -171,21 +172,15 @@ export default {
|
|||
...mapGetters(['options'])
|
||||
},
|
||||
created() {
|
||||
this.loadUser()
|
||||
this.getCounts()
|
||||
this.getStatistics()
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({ setUser: 'SET_USER' }),
|
||||
loadUser() {
|
||||
userApi.getProfile().then(response => {
|
||||
this.user = response.data.data
|
||||
this.profileLoading = false
|
||||
})
|
||||
},
|
||||
getCounts() {
|
||||
adminApi.counts().then(response => {
|
||||
this.counts = response.data.data
|
||||
this.countsLoading = false
|
||||
getStatistics() {
|
||||
statisticsApi.statisticsWithUser().then(response => {
|
||||
this.user = response.data.data.user
|
||||
this.statistics = response.data.data
|
||||
this.statisticsLoading = false
|
||||
})
|
||||
},
|
||||
handleUpdatePassword() {
|
||||
|
|
Loading…
Reference in New Issue