From 5cc91eca512e04da815d5bb5ad93cf70a8a13792 Mon Sep 17 00:00:00 2001 From: Junhui Chen Date: Sun, 7 Sep 2025 22:28:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wake/View/Owner/AccountView.swift | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/wake/View/Owner/AccountView.swift b/wake/View/Owner/AccountView.swift index 47fecfa..e477128 100644 --- a/wake/View/Owner/AccountView.swift +++ b/wake/View/Owner/AccountView.swift @@ -39,6 +39,16 @@ struct AccountView: View { // 内容区域 ScrollView { VStack(spacing: 0) { + // 注销登录 + settingRow( + title: "Log Out", + action: { + // 处理注销登录逻辑 + self.handleLogout() + } + ) + .padding() + // 删除账号 settingRow( title: "Delete Account", @@ -146,6 +156,22 @@ struct AccountView: View { // MARK: - 私有方法 + /// 处理用户登出逻辑 + private func handleLogout() { + // 1. 清除认证token + TokenManager.shared.clearTokens() + + // 2. 清除本地存储的用户信息 + UserDefaults.standard.removeObject(forKey: "lastLoginUser") + + // 3. 更新认证状态 + AuthState.shared.logout() + + // 4. 跳转到登录页面 + Router.shared.popToRoot() + Router.shared.navigate(to: .login) + } + /// 配置TableView外观 private func configureTableView() { // 移除列表底部分隔线