fix(widget): 修复用户信息保存条件并传递翻译函数
修复 store 中用户信息保存逻辑,仅在表单字段实际变化时保存,避免不必要的 localStorage 写入。同时向回复编辑器传递翻译函数以支持国际化。
This commit is contained in:
@@ -303,6 +303,7 @@ export class CommentItem extends Component {
|
|||||||
onCancel: () => this.handleCancelReply(),
|
onCancel: () => this.handleCancelReply(),
|
||||||
onClearError: () => this.handleClearReplyError(),
|
onClearError: () => this.handleClearReplyError(),
|
||||||
placeholder: this.props.replyPlaceholder,
|
placeholder: this.props.replyPlaceholder,
|
||||||
|
t: this.t
|
||||||
});
|
});
|
||||||
this.replyEditor.render();
|
this.replyEditor.render();
|
||||||
this.replyEditor.focus();
|
this.replyEditor.focus();
|
||||||
|
|||||||
@@ -133,8 +133,12 @@ export function createCommentStore(config, fetchComments, submitComment, likeCom
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 监听用户信息变化,自动保存到 localStorage
|
// 监听用户信息变化,自动保存到 localStorage
|
||||||
store.subscribe((state) => {
|
store.subscribe((state, prevState) => {
|
||||||
if (state.form.name || state.form.email || state.form.url) {
|
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);
|
saveUserInfo(state.form.name, state.form.email, state.form.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user