hookehuyr

🎈 perf: 优化作品留言回复逻辑

...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
27 <van-col offset="4" span="20"> 27 <van-col offset="4" span="20">
28 <div v-if="item.total" class="reply-wrapper"> 28 <div v-if="item.total" class="reply-wrapper">
29 <template v-for="(reply, index) in item.reply_list" :key="index"> 29 <template v-for="(reply, index) in item.reply_list" :key="index">
30 - <p v-if="reply.reply_to && index <= 3"> 30 + <p v-if="reply.reply_to && index <= reply_limit">
31 <span>{{ reply.name }}</span> 31 <span>{{ reply.name }}</span>
32 &nbsp;回复&nbsp; 32 &nbsp;回复&nbsp;
33 <span>@{{ reply.reply_to }}: </span> 33 <span>@{{ reply.reply_to }}: </span>
...@@ -271,8 +271,9 @@ const submitCommentBox = (note) => { ...@@ -271,8 +271,9 @@ const submitCommentBox = (note) => {
271 _.each(commentList.value, comment => { 271 _.each(commentList.value, comment => {
272 if (comment.id === commentId.value) { 272 if (comment.id === commentId.value) {
273 // 后面新增一条,删除第一条,保存列表数量不变 273 // 后面新增一条,删除第一条,保存列表数量不变
274 - comment.reply_list.shift()
275 comment.reply_list.push(res.data.data) 274 comment.reply_list.push(res.data.data)
275 + // 回复数量大于控制数量时才执行
276 + comment.reply_list.length > reply_limit.value ? comment.reply_list.shift() : '';
276 comment.total = comment.total + 1 277 comment.total = comment.total + 1
277 } 278 }
278 }) 279 })
......