mirror of https://github.com/halo-dev/halo-admin
feat: support render markdown in Comment Drawer.
parent
7ce36abc63
commit
9bd3d37a24
|
@ -597,6 +597,9 @@ body {
|
|||
p {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 0;
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
:sm="24"
|
||||
>
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="queryParam.keyword" />
|
||||
<a-input v-model="queryParam.keyword" @keyup.enter="handleQuery()"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
:sm="24"
|
||||
>
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="queryParam.keyword" />
|
||||
<a-input v-model="queryParam.keyword" @keyup.enter="handleQuery()"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<a-empty v-if="comments.length==0" />
|
||||
<TargetCommentTree
|
||||
v-else
|
||||
v-for="(comment, index) in comments"
|
||||
v-for="(comment, index) in formattedComments"
|
||||
:key="index"
|
||||
:comment="comment"
|
||||
@reply="handleCommentReply"
|
||||
|
@ -48,6 +48,7 @@
|
|||
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
||||
import TargetCommentTree from './TargetCommentTree'
|
||||
import commentApi from '@/api/comment'
|
||||
import marked from 'marked'
|
||||
export default {
|
||||
name: 'TargetCommentDrawer',
|
||||
mixins: [mixin, mixinDevice],
|
||||
|
@ -104,6 +105,14 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
formattedComments() {
|
||||
return this.comments.map(comment => {
|
||||
comment.content = marked(comment.content, { sanitize: true })
|
||||
return comment
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadComments() {
|
||||
this.queryParam.page = this.pagination.page - 1
|
||||
|
@ -123,6 +132,12 @@ export default {
|
|||
handleCommentDelete() {},
|
||||
|
||||
onClose() {
|
||||
this.comments = []
|
||||
this.pagination = {
|
||||
page: 1,
|
||||
size: 10,
|
||||
sort: ''
|
||||
}
|
||||
this.$emit('close', false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
:src="avatar"
|
||||
:alt="comment.author"
|
||||
/>
|
||||
<p slot="content">{{ comment.content }}</p>
|
||||
<p slot="content" v-html="comment.content"></p>
|
||||
<template v-if="comment.children">
|
||||
<TargetCommentTree
|
||||
v-for="(child, index) in comment.children"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
:sm="24"
|
||||
>
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="queryParam.keyword" />
|
||||
<a-input v-model="queryParam.keyword" @keyup.enter="handleQuery()"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
:sm="24"
|
||||
>
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="queryParam.keyword" />
|
||||
<a-input v-model="queryParam.keyword" @keyup.enter="handleQuery()"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
|
|
Loading…
Reference in New Issue