Commit 1c5d6821 by lijiabin

【需求 17679】 perf: 保持页面数据的一致

parent 7ba4f1e9
......@@ -139,7 +139,7 @@
<el-button
text
class="flex items-center gap-2 text-gray-500 transition-colors"
@click="handleComment(index)"
@click="handleComment(item)"
>
<el-icon><ChatDotRound /></el-icon>
<span class="text-sm">{{ item.replyCount || 0 }}</span>
......@@ -152,7 +152,7 @@
:id="item.id"
:total="item.replyCount"
:defaultSize="5"
@commentSuccess="() => handleCommentSuccess(index)"
@commentSuccess="() => handleCommentSuccess(item)"
/>
</Transition>
</el-card>
......@@ -252,12 +252,18 @@ const handleCollect = async (item: ArticleItemDto) => {
ElMessage.success(item.hasCollect ? '收藏成功' : '取消收藏')
}
const handleComment = (index: number) => {
list.value[index]!.showComment = !list.value[index]!.showComment
const handleComment = (item: ArticleItemDto) => {
item.showComment = !item.showComment
}
const handleCommentSuccess = (index: number) => {
list.value[index]!.replyCount++
const handleCommentSuccess = (item: ArticleItemDto) => {
item.replyCount++
// 同时更新下
// 如果已经添加了回答 则改为未添加 并且更新问题数量
if (item.hasAddQuestion) {
item.hasAddQuestion = false
fetchUserQestionNum()
}
}
const handleAddQuestion = async (item: ArticleItemDto) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment