优化kg评论区at显示 (#1515)

* 优化kg评论区at显示

* lint code

---------

Co-authored-by: lyswhut <lyswhut@qq.com>
pull/1583/head
彭狸花喵 2023-08-07 18:36:13 +08:00 committed by GitHub
parent aa6696dfcc
commit 31e16a7ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -53,11 +53,17 @@ export default {
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')
return { source: 'kg', comments: this.filterComment(body.list || []) }
},
replaceAt(raw, atList) {
atList.forEach((atobj) => {
raw = raw.replaceAll(`[at=${atobj.id}]`, `@${atobj.name} `)
})
return raw
},
filterComment(rawList) {
return rawList.map(item => {
let data = {
id: item.id,
text: decodeName(item.content || ''),
text: decodeName((item.atlist ? this.replaceAt(item.content, item.atlist) : item.content) || ''),
images: item.images ? item.images.map(i => i.url) : [],
location: item.location,
time: item.addtime,