diff --git a/XNSimHtml/components/todo-component.js b/XNSimHtml/components/todo-component.js
index ab27e99..0dbe14c 100644
--- a/XNSimHtml/components/todo-component.js
+++ b/XNSimHtml/components/todo-component.js
@@ -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);
\ No newline at end of file
diff --git a/XNSimHtml/main.html b/XNSimHtml/main.html
index 3a43cd0..6f7c088 100644
--- a/XNSimHtml/main.html
+++ b/XNSimHtml/main.html
@@ -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 || '登录失败,请检查用户名和密码');
}