修复了待办事项在切换用户时有数据残留的问题
This commit is contained in:
parent
0165c5c6ef
commit
98a1051611
@ -29,9 +29,8 @@ class TodoComponent extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isInitialized) {
|
||||
return;
|
||||
}
|
||||
// 先清除所有数据
|
||||
this.clearData();
|
||||
|
||||
TodoComponent.isInitializing = true;
|
||||
|
||||
@ -1047,6 +1046,19 @@ class TodoComponent extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
// 清除所有数据
|
||||
clearData() {
|
||||
this.todos = [];
|
||||
this.selectedProject = null;
|
||||
this.selectedSubproject = null;
|
||||
this.expandedProjects = new Set();
|
||||
this.users = [];
|
||||
this.currentUser = null;
|
||||
this.editingTodo = null;
|
||||
this.isInitialized = false;
|
||||
this.showCompleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('todo-component', TodoComponent);
|
@ -413,6 +413,7 @@
|
||||
localStorage.removeItem('userInfo');
|
||||
// 清除所有标签页
|
||||
tabsContainer.clearAllTabs();
|
||||
|
||||
// 显示退出成功提示
|
||||
showToast('已安全退出登录');
|
||||
|
||||
@ -689,6 +690,12 @@
|
||||
detail: { user: result.user }
|
||||
});
|
||||
document.dispatchEvent(loginSuccessEvent);
|
||||
|
||||
// 重新初始化todo-component
|
||||
const todoComponent = document.querySelector('todo-component');
|
||||
if (todoComponent) {
|
||||
todoComponent.initialize();
|
||||
}
|
||||
} else {
|
||||
showToast(result.message || '登录失败,请检查用户名和密码');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user