diff --git a/src/api/post.js b/src/api/post.js index c9b46efc7..0f2cd7d15 100644 --- a/src/api/post.js +++ b/src/api/post.js @@ -4,9 +4,12 @@ const baseUrl = '/api/admin/posts' const postApi = {} -postApi.listLatest = () => { +postApi.listLatest = (top) => { return service({ url: `${baseUrl}/latest`, + params: { + top: top + }, method: 'get' }) } diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index ef3118248..7c716f019 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -53,15 +53,16 @@ > - - - + + + 文章总访问共 {{ countsData.visitCount }} 次 + + + + - + 博客建立于 {{ countsData.birthday | moment }} @@ -99,11 +98,76 @@ :style="{ marginBottom: '12px' }" > - 最新文章 + + + + + 最近文章 + + + + + {{ item.title }} + + {{ item.createTime | timeAgo }} + + + + + + 最近评论 + + + + + + {{ item.author }} 发表在 《{{ item.post.title }}》 + + + 回复 + + {{ item.content }} + + {{ item.createTime | timeAgo }} + + + + + + + - 最新评论 + + 速记 + + + + + + + + + 保存 + + - 最新日志 + 日志记录 @@ -150,48 +233,7 @@ import postApi from '@/api/post' import commentApi from '@/api/comment' import logApi from '@/api/log' import adminApi from '@/api/admin' - -const postColumns = [ - { - title: '标题', - dataIndex: 'title', - scopedSlots: { customRender: 'name' } - }, - { - title: '状态', - className: 'status', - dataIndex: 'status', - scopedSlots: { customRender: 'status' } - }, - { - title: '最后编辑时间', - dataIndex: 'editTime', - scopedSlots: { customRender: 'editTime' } - } -] - -const commentColumns = [ - { - title: '评论者', - dataIndex: 'author', - scopedSlots: { customRender: 'name' } - }, - { - title: '状态', - className: 'status', - dataIndex: 'status' - }, - { - title: '内容', - className: 'content', - dataIndex: 'content' - }, - { - title: '发布时间', - dataIndex: 'date' - } -] - +import journalApi from '@/api/journal' export default { name: 'Dashboard', components: { @@ -200,16 +242,14 @@ export default { }, data() { return { - postLoading: true, - commentLoading: true, + activityLoading: true, logLoading: true, countsLoading: true, - postColumns, postData: [], - commentColumns, commentData: [], logData: [], - countsData: {} + countsData: {}, + journal: {} } }, created() { @@ -229,21 +269,21 @@ export default { }, methods: { listLatestPosts() { - postApi.listLatest().then(response => { - this.postLoading = false + postApi.listLatest(5).then(response => { this.postData = response.data.data + this.activityLoading = false }) }, listLatestComments() { - commentApi.listLatest().then(response => { - this.commentLoading = false + commentApi.listLatest(5, 'PUBLISHED').then(response => { this.commentData = response.data.data + this.activityLoading = false }) }, listLatestLogs() { logApi.listLatest().then(response => { - this.logLoading = false this.logData = response.data.data + this.logLoading = false }) }, getCounts() { @@ -251,10 +291,28 @@ export default { this.countsData = response.data.data this.countsLoading = false }) + }, + handleEditPostClick(post) { + this.$router.push({ name: 'PostEdit', query: { postId: post.id } }) + }, + handleCreateJournalClick() { + journalApi.create(this.journal).then(response => { + this.$message.success('发表成功!') + this.journal = {} + }) } } } diff --git a/src/views/sheet/internal/JournalList.vue b/src/views/sheet/internal/JournalList.vue index 013fd4f8e..564ea7815 100644 --- a/src/views/sheet/internal/JournalList.vue +++ b/src/views/sheet/internal/JournalList.vue @@ -84,6 +84,9 @@ />{{ item.commentCount }} + + From 微信 + - + + + {{ title }} + + + 支持 Hexo/Jekyll 导入并解析元数据
{{ item.content }}
支持 Hexo/Jekyll 导入并解析元数据