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 {