From e98dbeb7abc4c465361915e6771a95f21314526b Mon Sep 17 00:00:00 2001 From: anghunk Date: Thu, 12 Feb 2026 09:35:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(widget):=20=E4=BF=AE=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E4=BF=9D=E5=AD=98=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=B9=B6=E4=BC=A0=E9=80=92=E7=BF=BB=E8=AF=91=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 store 中用户信息保存逻辑,仅在表单字段实际变化时保存,避免不必要的 localStorage 写入。同时向回复编辑器传递翻译函数以支持国际化。 --- docs/widget/src/components/CommentItem.js | 1 + docs/widget/src/core/store.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/widget/src/components/CommentItem.js b/docs/widget/src/components/CommentItem.js index 571be54..9fe0b57 100644 --- a/docs/widget/src/components/CommentItem.js +++ b/docs/widget/src/components/CommentItem.js @@ -303,6 +303,7 @@ export class CommentItem extends Component { onCancel: () => this.handleCancelReply(), onClearError: () => this.handleClearReplyError(), placeholder: this.props.replyPlaceholder, + t: this.t }); this.replyEditor.render(); this.replyEditor.focus(); diff --git a/docs/widget/src/core/store.js b/docs/widget/src/core/store.js index e200a76..391fb59 100644 --- a/docs/widget/src/core/store.js +++ b/docs/widget/src/core/store.js @@ -133,8 +133,12 @@ export function createCommentStore(config, fetchComments, submitComment, likeCom }); // 监听用户信息变化,自动保存到 localStorage - store.subscribe((state) => { - if (state.form.name || state.form.email || state.form.url) { + store.subscribe((state, prevState) => { + if ( + state.form.name !== prevState.form.name || + state.form.email !== prevState.form.email || + state.form.url !== prevState.form.url + ) { saveUserInfo(state.form.name, state.form.email, state.form.url); } });