mirror of https://github.com/halo-dev/halo-admin
feat: support show comments in post list.
parent
814a814698
commit
1ba18f764d
|
@ -23,6 +23,14 @@ commentApi.queryComment = (target, params) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commentApi.commentTree = (target, id, params) => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/${target}/comments/${id}/tree_view`,
|
||||||
|
params: params,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
commentApi.updateStatus = (target, commentId, status) => {
|
commentApi.updateStatus = (target, commentId, status) => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/${target}/comments/${commentId}/status/${status}`,
|
url: `${baseUrl}/${target}/comments/${commentId}/status/${status}`,
|
||||||
|
|
|
@ -592,8 +592,6 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-comment-inner {
|
.ant-comment-inner {
|
||||||
padding: 0 !important;
|
|
||||||
|
|
||||||
.ant-comment-content {
|
.ant-comment-content {
|
||||||
.ant-comment-content-detail {
|
.ant-comment-content-detail {
|
||||||
p {
|
p {
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
<template>
|
||||||
|
<a-drawer
|
||||||
|
title="评论列表"
|
||||||
|
:width="isMobile()?'100%':'460'"
|
||||||
|
closable
|
||||||
|
:visible="visible"
|
||||||
|
destroyOnClose
|
||||||
|
@close="onClose"
|
||||||
|
>
|
||||||
|
<a-row
|
||||||
|
type="flex"
|
||||||
|
align="middle"
|
||||||
|
>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-list itemLayout="horizontal">
|
||||||
|
<a-list-item>
|
||||||
|
<a-list-item-meta :description="description">
|
||||||
|
<h3 slot="title">{{ title }}</h3>
|
||||||
|
</a-list-item-meta>
|
||||||
|
</a-list-item>
|
||||||
|
</a-list>
|
||||||
|
</a-col>
|
||||||
|
<a-divider />
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-empty v-if="comments.length==0" />
|
||||||
|
<TargetCommentTree
|
||||||
|
v-else
|
||||||
|
v-for="(comment, index) in comments"
|
||||||
|
:key="index"
|
||||||
|
:comment="comment"
|
||||||
|
@reply="handleCommentReply"
|
||||||
|
@delete="handleCommentDelete"
|
||||||
|
/>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-divider />
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<a-pagination
|
||||||
|
:defaultPageSize="pagination.size"
|
||||||
|
:total="pagination.total"
|
||||||
|
@change="handlePaginationChange"
|
||||||
|
></a-pagination>
|
||||||
|
</div>
|
||||||
|
</a-drawer>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
|
import TargetCommentTree from './TargetCommentTree'
|
||||||
|
import commentApi from '@/api/comment'
|
||||||
|
export default {
|
||||||
|
name: 'TargetCommentDrawer',
|
||||||
|
mixins: [mixin, mixinDevice],
|
||||||
|
components: { TargetCommentTree },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
comments: [],
|
||||||
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
size: 10,
|
||||||
|
sort: ''
|
||||||
|
},
|
||||||
|
queryParam: {
|
||||||
|
page: 0,
|
||||||
|
size: 10,
|
||||||
|
sort: null,
|
||||||
|
keyword: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
visible: function(newValue, oldValue) {
|
||||||
|
this.$log.debug('old value', oldValue)
|
||||||
|
this.$log.debug('new value', newValue)
|
||||||
|
if (newValue) {
|
||||||
|
this.loadComments()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadComments() {
|
||||||
|
this.queryParam.page = this.pagination.page - 1
|
||||||
|
this.queryParam.size = this.pagination.size
|
||||||
|
this.queryParam.sort = this.pagination.sort
|
||||||
|
commentApi.commentTree(this.target, this.id, this.queryParam).then(response => {
|
||||||
|
this.comments = response.data.data.content
|
||||||
|
this.pagination.total = response.data.data.total
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handlePaginationChange(page, pageSize) {
|
||||||
|
this.pagination.page = page
|
||||||
|
this.pagination.size = pageSize
|
||||||
|
this.loadComments()
|
||||||
|
},
|
||||||
|
handleCommentReply() {},
|
||||||
|
handleCommentDelete() {},
|
||||||
|
|
||||||
|
onClose() {
|
||||||
|
this.$emit('close', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,64 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span @click="handleReplyClick">回复</span>
|
||||||
|
<a-popconfirm
|
||||||
|
:title="'你确定要永久删除该评论?'"
|
||||||
|
@confirm="handleDeleteClick"
|
||||||
|
okText="确定"
|
||||||
|
cancelText="取消"
|
||||||
|
>
|
||||||
|
<span>删除</span>
|
||||||
|
</a-popconfirm>
|
||||||
|
</template>
|
||||||
|
<a slot="author">{{ comment.author }}</a>
|
||||||
|
<a-avatar
|
||||||
|
slot="avatar"
|
||||||
|
:src="avatar"
|
||||||
|
:alt="comment.author"
|
||||||
|
/>
|
||||||
|
<p slot="content">{{ comment.content }}</p>
|
||||||
|
<template v-if="comment.children">
|
||||||
|
<TargetCommentTree
|
||||||
|
v-for="(child, index) in comment.children"
|
||||||
|
:key="index"
|
||||||
|
:comment="child"
|
||||||
|
@reply="handleSubReply"
|
||||||
|
@delete="handleSubDelete"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</a-comment>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'TargetCommentTree',
|
||||||
|
props: {
|
||||||
|
comment: {
|
||||||
|
type: Object,
|
||||||
|
required: false,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
avatar() {
|
||||||
|
return `//cn.gravatar.com/avatar/${this.comment.gravatarMd5}/?s=256&d=mp`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleReplyClick() {
|
||||||
|
this.$emit('reply', this.comment)
|
||||||
|
},
|
||||||
|
handleSubReply(comment) {
|
||||||
|
this.$emit('reply', comment)
|
||||||
|
},
|
||||||
|
handleDeleteClick() {
|
||||||
|
this.$emit('delete', this.comment)
|
||||||
|
},
|
||||||
|
handleSubDelete(comment) {
|
||||||
|
this.$emit('delete', comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -27,7 +27,7 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
<PostSetting
|
<PostSettingDrawer
|
||||||
:post="postToStage"
|
:post="postToStage"
|
||||||
:tagIds="selectedTagIds"
|
:tagIds="selectedTagIds"
|
||||||
:categoryIds="selectedCategoryIds"
|
:categoryIds="selectedCategoryIds"
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import PostSetting from './components/PostSetting'
|
import PostSettingDrawer from './components/PostSettingDrawer'
|
||||||
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
||||||
import FooterToolBar from '@/components/FooterToolbar'
|
import FooterToolBar from '@/components/FooterToolbar'
|
||||||
import { toolbars } from '@/core/const'
|
import { toolbars } from '@/core/const'
|
||||||
|
@ -79,7 +79,7 @@ import attachmentApi from '@/api/attachment'
|
||||||
export default {
|
export default {
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
components: {
|
components: {
|
||||||
PostSetting,
|
PostSettingDrawer,
|
||||||
haloEditor,
|
haloEditor,
|
||||||
FooterToolBar,
|
FooterToolBar,
|
||||||
AttachmentDrawer
|
AttachmentDrawer
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
<a-icon type="eye" />
|
<a-icon type="eye" />
|
||||||
{{ item.visits }}
|
{{ item.visits }}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span @click="handleShowPostComments(item)">
|
||||||
<a-icon type="message" />
|
<a-icon type="message" />
|
||||||
{{ item.commentCount }}
|
{{ item.commentCount }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -390,10 +390,12 @@
|
||||||
|
|
||||||
<span
|
<span
|
||||||
slot="commentCount"
|
slot="commentCount"
|
||||||
slot-scope="commentCount"
|
slot-scope="text,record"
|
||||||
|
@click="handleShowPostComments(record)"
|
||||||
|
style="cursor: pointer;"
|
||||||
>
|
>
|
||||||
<a-badge
|
<a-badge
|
||||||
:count="commentCount"
|
:count="record.commentCount"
|
||||||
:numberStyle="{backgroundColor: '#f38181'} "
|
:numberStyle="{backgroundColor: '#f38181'} "
|
||||||
:showZero="true"
|
:showZero="true"
|
||||||
:overflowCount="999"
|
:overflowCount="999"
|
||||||
|
@ -486,7 +488,7 @@
|
||||||
</div>
|
</div>
|
||||||
</a-card>
|
</a-card>
|
||||||
|
|
||||||
<PostSetting
|
<PostSettingDrawer
|
||||||
:post="selectedPost"
|
:post="selectedPost"
|
||||||
:tagIds="selectedTagIds"
|
:tagIds="selectedTagIds"
|
||||||
:categoryIds="selectedCategoryIds"
|
:categoryIds="selectedCategoryIds"
|
||||||
|
@ -500,12 +502,22 @@
|
||||||
@onRefreshTagIds="onRefreshTagIdsFromSetting"
|
@onRefreshTagIds="onRefreshTagIdsFromSetting"
|
||||||
@onRefreshCategoryIds="onRefreshCategoryIdsFromSetting"
|
@onRefreshCategoryIds="onRefreshCategoryIdsFromSetting"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TargetCommentDrawer
|
||||||
|
:visible="postCommentVisible"
|
||||||
|
:title="selectedPost.title"
|
||||||
|
:description="selectedPost.summary"
|
||||||
|
:target="`posts`"
|
||||||
|
:id="selectedPost.id"
|
||||||
|
@close="onPostCommentsClose"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
import PostSetting from './components/PostSetting'
|
import PostSettingDrawer from './components/PostSettingDrawer'
|
||||||
|
import TargetCommentDrawer from '../comment/components/TargetCommentDrawer'
|
||||||
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
|
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
|
||||||
import TagSelect from './components/TagSelect'
|
import TagSelect from './components/TagSelect'
|
||||||
import CategoryTree from './components/CategoryTree'
|
import CategoryTree from './components/CategoryTree'
|
||||||
|
@ -566,7 +578,8 @@ export default {
|
||||||
AttachmentSelectDrawer,
|
AttachmentSelectDrawer,
|
||||||
TagSelect,
|
TagSelect,
|
||||||
CategoryTree,
|
CategoryTree,
|
||||||
PostSetting
|
PostSettingDrawer,
|
||||||
|
TargetCommentDrawer
|
||||||
},
|
},
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
data() {
|
data() {
|
||||||
|
@ -593,9 +606,11 @@ export default {
|
||||||
posts: [],
|
posts: [],
|
||||||
postsLoading: false,
|
postsLoading: false,
|
||||||
postSettingVisible: false,
|
postSettingVisible: false,
|
||||||
|
postCommentVisible: false,
|
||||||
selectedPost: {},
|
selectedPost: {},
|
||||||
selectedTagIds: [],
|
selectedTagIds: [],
|
||||||
selectedCategoryIds: []
|
selectedCategoryIds: [],
|
||||||
|
postComments: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -734,6 +749,12 @@ export default {
|
||||||
this.postSettingVisible = true
|
this.postSettingVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handleShowPostComments(post) {
|
||||||
|
postApi.get(post.id).then(response => {
|
||||||
|
this.selectedPost = response.data.data
|
||||||
|
this.postCommentVisible = true
|
||||||
|
})
|
||||||
|
},
|
||||||
handlePreview(postId) {
|
handlePreview(postId) {
|
||||||
postApi.preview(postId).then(response => {
|
postApi.preview(postId).then(response => {
|
||||||
window.open(response.data, '_blank')
|
window.open(response.data, '_blank')
|
||||||
|
@ -747,6 +768,13 @@ export default {
|
||||||
this.loadPosts()
|
this.loadPosts()
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
|
onPostCommentsClose() {
|
||||||
|
this.postCommentVisible = false
|
||||||
|
this.selectedPost = {}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.loadPosts()
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
onRefreshPostFromSetting(post) {
|
onRefreshPostFromSetting(post) {
|
||||||
this.selectedPost = post
|
this.selectedPost = post
|
||||||
},
|
},
|
||||||
|
|
|
@ -202,7 +202,7 @@ import { mapGetters } from 'vuex'
|
||||||
import categoryApi from '@/api/category'
|
import categoryApi from '@/api/category'
|
||||||
import postApi from '@/api/post'
|
import postApi from '@/api/post'
|
||||||
export default {
|
export default {
|
||||||
name: 'PostSetting',
|
name: 'PostSettingDrawer',
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
components: {
|
components: {
|
||||||
CategoryTree,
|
CategoryTree,
|
|
@ -26,7 +26,7 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
<SheetSetting
|
<SheetSettingDrawer
|
||||||
:sheet="sheetToStage"
|
:sheet="sheetToStage"
|
||||||
:visible="sheetSettingVisible"
|
:visible="sheetSettingVisible"
|
||||||
@close="onSheetSettingsClose"
|
@close="onSheetSettingsClose"
|
||||||
|
@ -62,7 +62,7 @@ import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { toolbars } from '@/core/const'
|
import { toolbars } from '@/core/const'
|
||||||
import SheetSetting from './components/SheetSetting'
|
import SheetSettingDrawer from './components/SheetSettingDrawer'
|
||||||
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
|
||||||
import FooterToolBar from '@/components/FooterToolbar'
|
import FooterToolBar from '@/components/FooterToolbar'
|
||||||
import { haloEditor } from 'halo-editor'
|
import { haloEditor } from 'halo-editor'
|
||||||
|
@ -74,7 +74,7 @@ export default {
|
||||||
haloEditor,
|
haloEditor,
|
||||||
FooterToolBar,
|
FooterToolBar,
|
||||||
AttachmentDrawer,
|
AttachmentDrawer,
|
||||||
SheetSetting
|
SheetSettingDrawer
|
||||||
},
|
},
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
data() {
|
data() {
|
||||||
|
|
|
@ -466,7 +466,7 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
<SheetSetting
|
<SheetSettingDrawer
|
||||||
:sheet="selectedSheet"
|
:sheet="selectedSheet"
|
||||||
:visible="sheetSettingVisible"
|
:visible="sheetSettingVisible"
|
||||||
:needTitle="true"
|
:needTitle="true"
|
||||||
|
@ -480,7 +480,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import SheetSetting from './components/SheetSetting'
|
import SheetSettingDrawer from './components/SheetSettingDrawer'
|
||||||
import sheetApi from '@/api/sheet'
|
import sheetApi from '@/api/sheet'
|
||||||
import menuApi from '@/api/menu'
|
import menuApi from '@/api/menu'
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ const customColumns = [
|
||||||
export default {
|
export default {
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
components: {
|
components: {
|
||||||
SheetSetting
|
SheetSettingDrawer
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -112,7 +112,7 @@ import { mapGetters } from 'vuex'
|
||||||
import themeApi from '@/api/theme'
|
import themeApi from '@/api/theme'
|
||||||
import sheetApi from '@/api/sheet'
|
import sheetApi from '@/api/sheet'
|
||||||
export default {
|
export default {
|
||||||
name: 'SheetSetting',
|
name: 'SheetSettingDrawer',
|
||||||
mixins: [mixin, mixinDevice],
|
mixins: [mixin, mixinDevice],
|
||||||
components: {
|
components: {
|
||||||
AttachmentSelectDrawer
|
AttachmentSelectDrawer
|
Loading…
Reference in New Issue