From 2056ba29d37b409c1d243a2ea42740edd228ed3c Mon Sep 17 00:00:00 2001 From: zpj80231 Date: Wed, 25 Mar 2026 15:32:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(widget):=20=E4=BF=AE=E5=A4=8D=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=88=97=E8=A1=A8=E4=B8=8B=E4=B8=80=E9=A1=B5=E3=80=81?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E9=A1=B5=E8=B6=85=E8=BF=87=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E9=A1=B5=E6=97=B6=E7=9A=84=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 onPrevPage 函数以获取当前状态而不是依赖闭包变量 - 修改 onNextPage 函数以获取当前状态而不是依赖闭包变量 - 添加显式的状态获取逻辑确保分页操作基于最新状态 - 提高代码可读性和状态管理的准确性 --- docs/widget/src/core/CWDComments.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/widget/src/core/CWDComments.js b/docs/widget/src/core/CWDComments.js index 0901f10..9602272 100644 --- a/docs/widget/src/core/CWDComments.js +++ b/docs/widget/src/core/CWDComments.js @@ -466,8 +466,14 @@ export class CWDComments { onUpdateReplyContent: (content) => this.store.updateReplyContent(content), onClearReplyError: () => this.store.clearReplyError(), replyPlaceholder: this.config.commentPlaceholder, - onPrevPage: () => this.store.goToPage(state.pagination.page - 1), - onNextPage: () => this.store.goToPage(state.pagination.page + 1), + onPrevPage: () => { + const currentState = this.store.store.getState(); + this.store.goToPage(currentState.pagination.page - 1); + }, + onNextPage: () => { + const currentState = this.store.store.getState(); + this.store.goToPage(currentState.pagination.page + 1); + }, onGoToPage: (page) => this.store.goToPage(page), onLikeComment: (commentId, isLike) => { if (this.store && typeof this.store.likeComment === 'function') {