mirror of https://github.com/halo-dev/halo-admin
🐛 Fix: Fix comment origin html tag perform (#222)
parent
c2864ef695
commit
3ceec997b1
|
@ -44,3 +44,12 @@ export function isObject(value) {
|
|||
export function datetimeFormat(value, pattern = 'YYYY-MM-DD HH:mm') {
|
||||
return moment(value).format(pattern)
|
||||
}
|
||||
|
||||
// decode html tag
|
||||
export function decodeHTML(html) {
|
||||
let elem = document.createElement('div')
|
||||
elem.innerHTML = html
|
||||
const output = elem.innerText || elem.textContent
|
||||
elem = null
|
||||
return output
|
||||
}
|
||||
|
|
|
@ -441,6 +441,8 @@ import { mixin, mixinDevice } from '@/utils/mixin.js'
|
|||
import CommentDetail from './CommentDetail'
|
||||
import marked from 'marked'
|
||||
import commentApi from '@/api/comment'
|
||||
import { decodeHTML } from '@/utils/util'
|
||||
|
||||
const postColumns = [
|
||||
{
|
||||
title: '昵称',
|
||||
|
@ -576,7 +578,7 @@ export default {
|
|||
formattedComments() {
|
||||
return this.comments.map(comment => {
|
||||
comment.statusProperty = this.commentStatus[comment.status]
|
||||
comment.content = marked(comment.content)
|
||||
comment.content = marked(decodeHTML(comment.content))
|
||||
return comment
|
||||
})
|
||||
}
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
</template>
|
||||
<script>
|
||||
import marked from 'marked'
|
||||
import { decodeHTML } from '@/utils/util'
|
||||
|
||||
export default {
|
||||
name: 'TargetCommentTree',
|
||||
props: {
|
||||
|
@ -111,7 +113,7 @@ export default {
|
|||
return `//cn.gravatar.com/avatar/${this.comment.gravatarMd5}/?s=256&d=mp`
|
||||
},
|
||||
content() {
|
||||
return marked(this.comment.content)
|
||||
return marked(decodeHTML(this.comment.content))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
Loading…
Reference in New Issue