Skip to content

Commit e98dbeb

Browse files
committed
fix(widget): 修复用户信息保存条件并传递翻译函数
修复 store 中用户信息保存逻辑,仅在表单字段实际变化时保存,避免不必要的 localStorage 写入。同时向回复编辑器传递翻译函数以支持国际化。
1 parent 507a897 commit e98dbeb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/widget/src/components/CommentItem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export class CommentItem extends Component {
303303
onCancel: () => this.handleCancelReply(),
304304
onClearError: () => this.handleClearReplyError(),
305305
placeholder: this.props.replyPlaceholder,
306+
t: this.t
306307
});
307308
this.replyEditor.render();
308309
this.replyEditor.focus();

docs/widget/src/core/store.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ export function createCommentStore(config, fetchComments, submitComment, likeCom
133133
});
134134

135135
// 监听用户信息变化,自动保存到 localStorage
136-
store.subscribe((state) => {
137-
if (state.form.name || state.form.email || state.form.url) {
136+
store.subscribe((state, prevState) => {
137+
if (
138+
state.form.name !== prevState.form.name ||
139+
state.form.email !== prevState.form.email ||
140+
state.form.url !== prevState.form.url
141+
) {
138142
saveUserInfo(state.form.name, state.form.email, state.form.url);
139143
}
140144
});

0 commit comments

Comments
 (0)