Refactor comment management.

pull/9/head
ruibaby 2019-05-16 14:39:35 +08:00
parent c5be555e02
commit 85f5114499
5 changed files with 26 additions and 28 deletions

View File

@ -0,0 +1,8 @@
<template>
<div></div>
</template>
<script>
export default {}
</script>
<style lang="less" scoped>
</style>

View File

@ -21,7 +21,7 @@
<script>
import { PageView } from '@/layouts'
import CommentTab from './CommentTab'
import CommentTab from './components/CommentTab'
export default {
components: {
PageView,

View File

@ -321,7 +321,7 @@ export default {
type: {
type: String,
required: false,
default: 'post',
default: 'posts',
validator: function(value) {
return ['posts', 'sheets', 'journals'].indexOf(value) !== -1
}

View File

@ -136,19 +136,19 @@
tab="文章"
key="1"
>
<recent-comment-tab type="post"></recent-comment-tab>
<recent-comment-tab type="posts"></recent-comment-tab>
</a-tab-pane>
<a-tab-pane
tab="页面"
key="2"
>
<recent-comment-tab type="sheet"></recent-comment-tab>
<recent-comment-tab type="sheets"></recent-comment-tab>
</a-tab-pane>
<a-tab-pane
tab="日志"
key="3"
>
<recent-comment-tab type="journal"></recent-comment-tab>
<recent-comment-tab type="journals"></recent-comment-tab>
</a-tab-pane>
</a-tabs>
</div>

View File

@ -10,12 +10,18 @@
:key="index"
>
<a-comment :avatar="'//gravatar.loli.net/avatar/'+item.gavatarMd5+'/?s=256&d=mp'">
<template slot="author">
<template slot="author" v-if="type==='posts'">
{{ item.author }} 发表在 <a
href="javascript:void(0);"
target="_blank"
>{{ item.post.title }}</a>
</template>
<template slot="author" v-else-if="type==='sheets'">
{{ item.author }} 发表在 <a
href="javascript:void(0);"
target="_blank"
>{{ item.sheet.title }}</a>
</template>
<template slot="actions">
<span>回复</span>
</template>
@ -44,9 +50,9 @@ export default {
type: {
type: String,
required: false,
default: 'post',
default: 'posts',
validator: function(value) {
return ['post', 'sheet', 'journal'].indexOf(value) !== -1
return ['posts', 'sheets', 'journals'].indexOf(value) !== -1
}
}
},
@ -70,26 +76,10 @@ export default {
methods: {
loadComments() {
this.loading = true
switch (this.type) {
case 'post':
commentApi.latestPostComment(5, 'PUBLISHED').then(response => {
this.comments = response.data.data
this.loading = false
})
break
case 'sheet':
commentApi.latestSheetComment(5, 'PUBLISHED').then(response => {
this.comments = response.data.data
this.loading = false
})
break
case 'journal':
commentApi.latestJournalComment(5, 'PUBLISHED').then(response => {
this.comments = response.data.data
this.loading = false
})
break
}
commentApi.latestComment(this.type, 5, 'PUBLISHED').then(response => {
this.comments = response.data.data
this.loading = false
})
}
}
}