mirror of https://github.com/halo-dev/halo
Refactor comment management.
parent
c5be555e02
commit
85f5114499
|
@ -0,0 +1,8 @@
|
||||||
|
<template>
|
||||||
|
<div></div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {}
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
</style>
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
|
@ -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>
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue