Refactor comment management.

pull/3445/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> <script>
import { PageView } from '@/layouts' import { PageView } from '@/layouts'
import CommentTab from './CommentTab' import CommentTab from './components/CommentTab'
export default { export default {
components: { components: {
PageView, PageView,

View File

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

View File

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

View File

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