feat: 新增注销帐号功能以增强用户交互体验
- 在APIEndpoints中新增注销帐号的API路径。 - 在AppSettingFeature中添加showDeactivateAccount状态和相关动作,支持注销帐号的逻辑。 - 在AppSettingView中整合注销帐号的视图逻辑,新增注销帐号行和绑定。 - 在Localizable.strings中添加英文和中文的注销帐号文本支持。
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -125,6 +125,7 @@
|
||||
"appSetting.checkUpdates" = "检查更新";
|
||||
"appSetting.logout" = "退出登录";
|
||||
"appSetting.aboutUs" = "关于我们";
|
||||
"appSetting.deactivateAccount" = "注销帐号";
|
||||
"appSetting.logoutAccount" = "退出账户";
|
||||
|
||||
// MARK: - Detail
|
||||
|
@@ -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<AppSettingFeature>) -> some View {
|
||||
settingRow(
|
||||
title: NSLocalizedString("appSetting.deactivateAccount", comment: "Deactivate Account"),
|
||||
action: { viewStore.send(.deactivateAccountTapped) }
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - 关于我们行
|
||||
private func aboutUsRow(viewStore: ViewStoreOf<AppSettingFeature>) -> some View {
|
||||
settingRow(
|
||||
@@ -404,6 +416,14 @@ struct AppSettingView: View {
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - 注销帐号绑定
|
||||
private func deactivateAccountBinding(viewStore: ViewStoreOf<AppSettingFeature>) -> Binding<Bool> {
|
||||
viewStore.binding(
|
||||
get: \.showDeactivateAccount,
|
||||
send: AppSettingFeature.Action.deactivateAccountDismissed
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - 昵称Alert内容
|
||||
@ViewBuilder
|
||||
private func nicknameAlertContent(viewStore: ViewStoreOf<AppSettingFeature>) -> some View {
|
||||
|
Reference in New Issue
Block a user