98b7600797
对标安卓正式版、对接 app-server(8770)的 SwiftUI 客户端。iOS 无障碍受限、无比价核心,做自成一体:美团 CPS 导购 + 福利(签到/任务/金币)+ 查看(比价记录/省钱战绩)。 功能完整 M0-M5:脚手架、短信登录(JWT+Keychain+401 自动刷新)、首页券 feed 导购、比价记录+省钱战绩、福利、我的(资料/反馈/设置/注销)。 单 target、0 三方依赖、XcodeGen 生成工程;Debug/Release 双 plist 分流 ATS。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
1.9 KiB
Swift
53 lines
1.9 KiB
Swift
import SwiftUI
|
|
import UIKit
|
|
|
|
/// 设置。iOS 无无障碍/悬浮窗那套权限卡(安卓特有),只保留账户/通用。
|
|
struct SettingsView: View {
|
|
@Environment(SessionStore.self) private var session
|
|
@State private var showDeleteConfirm = false
|
|
@State private var deleting = false
|
|
private let service = UserService()
|
|
|
|
var body: some View {
|
|
List {
|
|
Section("通用") {
|
|
NavigationLink { AboutView() } label: { Label("关于傻瓜比价", systemImage: "info.circle") }
|
|
NavigationLink { PrivacyPolicyView() } label: { Label("隐私政策", systemImage: "lock.shield") }
|
|
Button {
|
|
if let url = URL(string: UIApplication.openSettingsURLString) {
|
|
UIApplication.shared.open(url)
|
|
}
|
|
} label: {
|
|
Label("通知设置", systemImage: "bell")
|
|
}
|
|
}
|
|
|
|
Section {
|
|
Button(role: .destructive) {
|
|
showDeleteConfirm = true
|
|
} label: {
|
|
Text(deleting ? "注销中…" : "注销账号")
|
|
}
|
|
.disabled(deleting)
|
|
} footer: {
|
|
Text("注销后,你的资料、金币、记录将被删除或匿名化,不可恢复。")
|
|
}
|
|
}
|
|
.navigationTitle("设置")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.alert("确认注销账号?", isPresented: $showDeleteConfirm) {
|
|
Button("注销", role: .destructive) { Task { await deleteAccount() } }
|
|
Button("取消", role: .cancel) {}
|
|
} message: {
|
|
Text("此操作不可恢复。")
|
|
}
|
|
}
|
|
|
|
private func deleteAccount() async {
|
|
deleting = true
|
|
defer { deleting = false }
|
|
_ = try? await service.deleteAccount()
|
|
await session.logout() // 注销后登出;ProfileView 切回登录引导,导航栈自动重置
|
|
}
|
|
}
|