fix(widget): 修复用户信息保存条件并传递翻译函数

修复 store 中用户信息保存逻辑,仅在表单字段实际变化时保存,避免不必要的 localStorage 写入。同时向回复编辑器传递翻译函数以支持国际化。
This commit is contained in:
anghunk
2026-02-12 09:35:01 +08:00
parent 507a897b66
commit e98dbeb7ab
2 changed files with 7 additions and 2 deletions

View File

@@ -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();

View File

@@ -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);
}
});