feat: 评论嵌套规则修复

This commit is contained in:
tim
2025-08-04 02:04:31 +08:00
parent 354cc7cd17
commit ba8babd68a
2 changed files with 47 additions and 22 deletions

View File

@@ -216,17 +216,18 @@ export default {
}
}
const mapComment = (c, level = 0) => ({
const mapComment = (c, parentUserName = '', level = 0) => ({
id: c.id,
userName: c.author.username,
time: TimeManager.format(c.createdAt),
avatar: c.author.avatar,
text: c.content,
reactions: c.reactions || [],
reply: (c.replies || []).map(r => mapComment(r, level + 1)),
reply: (c.replies || []).map(r => mapComment(r, c.author.username, level + 1)),
openReplies: level === 0,
src: c.author.avatar,
iconClick: () => router.push(`/users/${c.author.id}`)
iconClick: () => router.push(`/users/${c.author.id}`),
parentUserName: parentUserName
})
const getTopRelativeTo = (el, container) => {