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') {
|
export function datetimeFormat(value, pattern = 'YYYY-MM-DD HH:mm') {
|
||||||
return moment(value).format(pattern)
|
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 CommentDetail from './CommentDetail'
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
import commentApi from '@/api/comment'
|
import commentApi from '@/api/comment'
|
||||||
|
import { decodeHTML } from '@/utils/util'
|
||||||
|
|
||||||
const postColumns = [
|
const postColumns = [
|
||||||
{
|
{
|
||||||
title: '昵称',
|
title: '昵称',
|
||||||
|
@ -576,7 +578,7 @@ export default {
|
||||||
formattedComments() {
|
formattedComments() {
|
||||||
return this.comments.map(comment => {
|
return this.comments.map(comment => {
|
||||||
comment.statusProperty = this.commentStatus[comment.status]
|
comment.statusProperty = this.commentStatus[comment.status]
|
||||||
comment.content = marked(comment.content)
|
comment.content = marked(decodeHTML(comment.content))
|
||||||
return comment
|
return comment
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,8 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
|
import { decodeHTML } from '@/utils/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TargetCommentTree',
|
name: 'TargetCommentTree',
|
||||||
props: {
|
props: {
|
||||||
|
@ -111,7 +113,7 @@ export default {
|
||||||
return `//cn.gravatar.com/avatar/${this.comment.gravatarMd5}/?s=256&d=mp`
|
return `//cn.gravatar.com/avatar/${this.comment.gravatarMd5}/?s=256&d=mp`
|
||||||
},
|
},
|
||||||
content() {
|
content() {
|
||||||
return marked(this.comment.content)
|
return marked(decodeHTML(this.comment.content))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue