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