From 6a9dd3fe5227e358beec648c15f9b59dde71330e Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Mon, 28 Jul 2025 17:59:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=B3=A8=E9=94=80?= =?UTF-8?q?=E5=B8=90=E5=8F=B7=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BA=A4=E4=BA=92=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在APIEndpoints中新增注销帐号的API路径。 - 在AppSettingFeature中添加showDeactivateAccount状态和相关动作,支持注销帐号的逻辑。 - 在AppSettingView中整合注销帐号的视图逻辑,新增注销帐号行和绑定。 - 在Localizable.strings中添加英文和中文的注销帐号文本支持。 --- yana/APIs/APIEndpoints.swift | 1 + yana/Features/AppSettingFeature.swift | 11 ++++++++++ yana/Resources/en.lproj/Localizable.strings | 1 + .../zh-Hans.lproj/Localizable.strings | 1 + yana/Views/AppSettingView.swift | 20 +++++++++++++++++++ 5 files changed, 34 insertions(+) diff --git a/yana/APIs/APIEndpoints.swift b/yana/APIs/APIEndpoints.swift index ae288e3..9390cd2 100644 --- a/yana/APIs/APIEndpoints.swift +++ b/yana/APIs/APIEndpoints.swift @@ -31,6 +31,7 @@ enum APIEndpoint: String, CaseIterable { // Web 页面路径 case userAgreement = "/modules/rule/protocol.html" case privacyPolicy = "/modules/rule/privacy-wap.html" + case deactivateAccount = "/modules/logout/confirm.html" var path: String { diff --git a/yana/Features/AppSettingFeature.swift b/yana/Features/AppSettingFeature.swift index d91a770..6109a36 100644 --- a/yana/Features/AppSettingFeature.swift +++ b/yana/Features/AppSettingFeature.swift @@ -14,6 +14,7 @@ struct AppSettingFeature { // WebView 导航状态 var showUserAgreement: Bool = false var showPrivacyPolicy: Bool = false + var showDeactivateAccount: Bool = false // 头像/昵称修改相关 var isUploadingAvatar: Bool = false @@ -49,10 +50,12 @@ struct AppSettingFeature { case clearCacheTapped case checkUpdatesTapped case aboutUsTapped + case deactivateAccountTapped // WebView 关闭 case userAgreementDismissed case privacyPolicyDismissed + case deactivateAccountDismissed // 头像/昵称修改 case avatarTapped @@ -143,6 +146,10 @@ struct AppSettingFeature { // 预留关于我们逻辑 return .none + case .deactivateAccountTapped: + state.showDeactivateAccount = true + return .none + case .userAgreementDismissed: state.showUserAgreement = false return .none @@ -151,6 +158,10 @@ struct AppSettingFeature { state.showPrivacyPolicy = false return .none + case .deactivateAccountDismissed: + state.showDeactivateAccount = false + return .none + case .avatarTapped: // 触发头像选择器 return .none diff --git a/yana/Resources/en.lproj/Localizable.strings b/yana/Resources/en.lproj/Localizable.strings index 3328252..6ff4518 100644 --- a/yana/Resources/en.lproj/Localizable.strings +++ b/yana/Resources/en.lproj/Localizable.strings @@ -129,6 +129,7 @@ "appSetting.checkUpdates" = "Check for Updates"; "appSetting.logout" = "Log Out"; "appSetting.aboutUs" = "About Us"; +"appSetting.deactivateAccount" = "Deactivate Account"; "appSetting.logoutAccount" = "Log out of account"; // MARK: - Detail diff --git a/yana/Resources/zh-Hans.lproj/Localizable.strings b/yana/Resources/zh-Hans.lproj/Localizable.strings index 19b532f..3fbf70a 100644 --- a/yana/Resources/zh-Hans.lproj/Localizable.strings +++ b/yana/Resources/zh-Hans.lproj/Localizable.strings @@ -125,6 +125,7 @@ "appSetting.checkUpdates" = "检查更新"; "appSetting.logout" = "退出登录"; "appSetting.aboutUs" = "关于我们"; +"appSetting.deactivateAccount" = "注销帐号"; "appSetting.logoutAccount" = "退出账户"; // MARK: - Detail diff --git a/yana/Views/AppSettingView.swift b/yana/Views/AppSettingView.swift index 2736341..1ed3e7c 100644 --- a/yana/Views/AppSettingView.swift +++ b/yana/Views/AppSettingView.swift @@ -113,6 +113,9 @@ struct AppSettingView: View { .sheet(isPresented: privacyPolicyBinding(viewStore: viewStore)) { WebView(url: APIConfiguration.webURL(for: .privacyPolicy)!) } + .sheet(isPresented: deactivateAccountBinding(viewStore: viewStore)) { + WebView(url: APIConfiguration.webURL(for: .deactivateAccount)!) + } } @ViewBuilder @@ -304,6 +307,7 @@ struct AppSettingView: View { helpRow(viewStore: viewStore) clearCacheRow(viewStore: viewStore) checkUpdatesRow(viewStore: viewStore) + deactivateAccountRow(viewStore: viewStore) aboutUsRow(viewStore: viewStore) } .background(Color.clear) @@ -342,6 +346,14 @@ struct AppSettingView: View { ) } + // MARK: - 注销帐号行 + private func deactivateAccountRow(viewStore: ViewStoreOf) -> some View { + settingRow( + title: NSLocalizedString("appSetting.deactivateAccount", comment: "Deactivate Account"), + action: { viewStore.send(.deactivateAccountTapped) } + ) + } + // MARK: - 关于我们行 private func aboutUsRow(viewStore: ViewStoreOf) -> some View { settingRow( @@ -404,6 +416,14 @@ struct AppSettingView: View { ) } + // MARK: - 注销帐号绑定 + private func deactivateAccountBinding(viewStore: ViewStoreOf) -> Binding { + viewStore.binding( + get: \.showDeactivateAccount, + send: AppSettingFeature.Action.deactivateAccountDismissed + ) + } + // MARK: - 昵称Alert内容 @ViewBuilder private func nicknameAlertContent(viewStore: ViewStoreOf) -> some View {