From 98a1051611c58a5795e11752cdfd4bf56175cd97 Mon Sep 17 00:00:00 2001 From: jinchao <383321154@qq.com> Date: Tue, 13 May 2025 09:58:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E4=BA=8B=E9=A1=B9=E5=9C=A8=E5=88=87=E6=8D=A2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=B6=E6=9C=89=E6=95=B0=E6=8D=AE=E6=AE=8B=E7=95=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XNSimHtml/components/todo-component.js | 18 +++++++++++++++--- XNSimHtml/main.html | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) 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 || '登录失败,请检查用户名和密码'); }