From dc8ba46f8622a8d0e2ab95098f91855a9bce2b12 Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Thu, 31 Jul 2025 18:39:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=99=BB=E5=87=BA?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E9=80=BB=E8=BE=91=E5=92=8C=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改MainFeature以将登出操作的Action名称从.logoutTapped更新为.logoutConfirmed,增强逻辑清晰度。 - 在AppSettingView中新增登出确认弹窗的实现,替换原有的登出确认逻辑,提升用户体验和交互性。 - 确保弹窗内容本地化,增强多语言支持。 --- yana/Features/MainFeature.swift | 4 +-- yana/Views/AppSettingView.swift | 62 ++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/yana/Features/MainFeature.swift b/yana/Features/MainFeature.swift index e034abd..65f954e 100644 --- a/yana/Features/MainFeature.swift +++ b/yana/Features/MainFeature.swift @@ -114,8 +114,8 @@ struct MainFeature { state.appSettingState = AppSettingFeature.State(nickname: nickname, avatarURL: avatarURL, userInfo: userInfo) state.navigationPath.append(.appSetting) return .none - case .appSettingAction(.logoutTapped): - // 监听到登出,设置登出标志 + case .appSettingAction(.logoutConfirmed): + // 监听到确认登出,设置登出标志 state.isLoggedOut = true return .none case .appSettingAction(.dismissTapped): diff --git a/yana/Views/AppSettingView.swift b/yana/Views/AppSettingView.swift index d515f9d..88a6cb2 100644 --- a/yana/Views/AppSettingView.swift +++ b/yana/Views/AppSettingView.swift @@ -24,6 +24,37 @@ struct AppSettingView: View { .onAppear { store.send(.onAppear) } + // 登出确认弹窗 + .alert(LocalizedString("appSetting.logoutConfirmation.title", comment: "确认退出"), isPresented: Binding( + get: { store.showLogoutConfirmation }, + set: { store.send(.showLogoutConfirmation($0)) } + )) { + Button(LocalizedString("common.cancel", comment: "取消"), role: .cancel) { + store.send(.showLogoutConfirmation(false)) + } + Button(LocalizedString("appSetting.logoutConfirmation.confirm", comment: "确认退出"), role: .destructive) { + store.send(.logoutConfirmed) + store.send(.showLogoutConfirmation(false)) + } + } message: { + Text(LocalizedString("appSetting.logoutConfirmation.message", comment: "确定要退出当前账户吗?")) + } + // 关于我们弹窗 + .alert(LocalizedString("appSetting.aboutUs.title", comment: "关于我们"), isPresented: Binding( + get: { store.showAboutUs }, + set: { store.send(.showAboutUs($0)) } + )) { + Button(LocalizedString("common.ok", comment: "确定")) { + store.send(.showAboutUs(false)) + } + } message: { + VStack(alignment: .leading, spacing: 8) { + Text(LocalizedString("feedList.title", comment: "享受您的生活时光")) + .font(.headline) + Text(LocalizedString("feedList.slogan", comment: "疾病如同残酷的统治者,\n而时间是我们最宝贵的财富。\n我们活着的每一刻,都是对不可避免命运的胜利。")) + .font(.body) + } + } } @ViewBuilder @@ -199,37 +230,6 @@ struct AppSettingView: View { ) viewWithDeactivateAccount - // 登出确认弹窗 - .alert(LocalizedString("appSetting.logoutConfirmation.title", comment: "确认退出"), isPresented: Binding( - get: { store.showLogoutConfirmation }, - set: { store.send(.showLogoutConfirmation($0)) } - )) { - Button(LocalizedString("common.cancel", comment: "取消"), role: .cancel) { - store.send(.showLogoutConfirmation(false)) - } - Button(LocalizedString("appSetting.logoutConfirmation.confirm", comment: "确认退出"), role: .destructive) { - store.send(.logoutConfirmed) - store.send(.showLogoutConfirmation(false)) - } - } message: { - Text(LocalizedString("appSetting.logoutConfirmation.message", comment: "确定要退出当前账户吗?")) - } - // 关于我们弹窗 - .alert(LocalizedString("appSetting.aboutUs.title", comment: "关于我们"), isPresented: Binding( - get: { store.showAboutUs }, - set: { store.send(.showAboutUs($0)) } - )) { - Button(LocalizedString("common.ok", comment: "确定")) { - store.send(.showAboutUs(false)) - } - } message: { - VStack(alignment: .leading, spacing: 8) { - Text(LocalizedString("feedList.title", comment: "享受您的生活时光")) - .font(.headline) - Text(LocalizedString("feedList.slogan", comment: "疾病如同残酷的统治者,\n而时间是我们最宝贵的财富。\n我们活着的每一刻,都是对不可避免命运的胜利。")) - .font(.body) - } - } } }