
- 注释掉Podfile中的Alamofire依赖,更新Podfile.lock以反映更改。 - 在yana/APIs/API-README.md中新增自动认证Header机制的详细文档,描述其工作原理、实现细节及最佳实践。 - 在yana/yanaApp.swift中将print语句替换为debugInfo以增强调试信息的输出。 - 在API相关文件中实现用户认证状态检查和相关header的自动添加逻辑,提升API请求的安全性和用户体验。 - 更新多个文件中的日志输出,确保在DEBUG模式下提供详细的调试信息。
200 lines
8.7 KiB
Swift
200 lines
8.7 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
|
||
struct SettingView: View {
|
||
let store: StoreOf<SettingFeature>
|
||
@ObservedObject private var localizationManager = LocalizationManager.shared
|
||
|
||
var body: some View {
|
||
WithPerceptionTracking {
|
||
GeometryReader { geometry in
|
||
ZStack {
|
||
// 背景图片 - 使用"bg"图片,全屏显示
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.ignoresSafeArea(.all)
|
||
|
||
VStack(spacing: 0) {
|
||
// Navigation Bar
|
||
HStack {
|
||
// 返回按钮
|
||
Button(action: {
|
||
store.send(.dismissTapped)
|
||
}) {
|
||
Image(systemName: "chevron.left")
|
||
.font(.title2)
|
||
.foregroundColor(.white)
|
||
}
|
||
.padding(.leading, 16)
|
||
|
||
Spacer()
|
||
|
||
// 标题
|
||
Text("设置")
|
||
.font(.custom("PingFang SC-Semibold", size: 16))
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
// 占位符,保持标题居中
|
||
Color.clear
|
||
.frame(width: 44, height: 44)
|
||
}
|
||
.padding(.top, 8)
|
||
.padding(.horizontal)
|
||
|
||
// 内容区域
|
||
ScrollView {
|
||
VStack(spacing: 24) {
|
||
// 用户信息卡片
|
||
VStack(spacing: 16) {
|
||
// 头像区域
|
||
Image(systemName: "person.circle.fill")
|
||
.font(.system(size: 60))
|
||
.foregroundColor(.white.opacity(0.8))
|
||
|
||
// 用户信息
|
||
VStack(spacing: 8) {
|
||
if let userInfo = store.userInfo, let userName = userInfo.username {
|
||
Text(userName)
|
||
.font(.title2.weight(.semibold))
|
||
.foregroundColor(.white)
|
||
} else {
|
||
Text("用户")
|
||
.font(.title2.weight(.semibold))
|
||
.foregroundColor(.white)
|
||
}
|
||
|
||
// 显示用户ID
|
||
if let userInfo = store.userInfo, let userId = userInfo.userId {
|
||
Text("ID: \(userId)")
|
||
.font(.caption)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
} else if let accountModel = store.accountModel, let uid = accountModel.uid {
|
||
Text("UID: \(uid)")
|
||
.font(.caption)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
}
|
||
}
|
||
}
|
||
.padding(.vertical, 24)
|
||
.padding(.horizontal, 20)
|
||
.background(Color.black.opacity(0.3))
|
||
.cornerRadius(16)
|
||
.padding(.horizontal, 24)
|
||
.padding(.top, 32)
|
||
|
||
// 设置选项列表
|
||
VStack(spacing: 12) {
|
||
// 语言设置
|
||
SettingRowView(
|
||
icon: "globe",
|
||
title: "语言设置",
|
||
action: {
|
||
// TODO: 实现语言设置
|
||
}
|
||
)
|
||
|
||
// 关于我们
|
||
SettingRowView(
|
||
icon: "info.circle",
|
||
title: "关于我们",
|
||
action: {
|
||
// TODO: 实现关于页面
|
||
}
|
||
)
|
||
|
||
// 版本信息
|
||
HStack {
|
||
Image(systemName: "app.badge")
|
||
.foregroundColor(.white.opacity(0.8))
|
||
.frame(width: 24)
|
||
|
||
Text("版本信息")
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
Text("1.0.0")
|
||
.foregroundColor(.white.opacity(0.6))
|
||
.font(.caption)
|
||
}
|
||
.padding(.horizontal, 20)
|
||
.padding(.vertical, 16)
|
||
.background(Color.black.opacity(0.2))
|
||
.cornerRadius(12)
|
||
}
|
||
.padding(.horizontal, 24)
|
||
|
||
Spacer(minLength: 50)
|
||
|
||
// 退出登录按钮
|
||
Button(action: {
|
||
store.send(.logoutTapped)
|
||
}) {
|
||
HStack {
|
||
Image(systemName: "arrow.right.square")
|
||
Text("退出登录")
|
||
}
|
||
.font(.body.weight(.medium))
|
||
.foregroundColor(.white)
|
||
.frame(maxWidth: .infinity)
|
||
.padding(.vertical, 16)
|
||
.background(Color.red.opacity(0.7))
|
||
.cornerRadius(12)
|
||
}
|
||
.padding(.horizontal, 24)
|
||
.padding(.bottom, 50)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.onAppear {
|
||
store.send(.onAppear)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// MARK: - Setting Row View
|
||
struct SettingRowView: View {
|
||
let icon: String
|
||
let title: String
|
||
let action: () -> Void
|
||
|
||
var body: some View {
|
||
Button(action: action) {
|
||
HStack {
|
||
Image(systemName: icon)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
.frame(width: 24)
|
||
|
||
Text(title)
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
Image(systemName: "chevron.right")
|
||
.foregroundColor(.white.opacity(0.6))
|
||
.font(.caption)
|
||
}
|
||
.padding(.horizontal, 20)
|
||
.padding(.vertical, 16)
|
||
.background(Color.black.opacity(0.2))
|
||
.cornerRadius(12)
|
||
}
|
||
}
|
||
}
|
||
|
||
//#Preview {
|
||
// SettingView(
|
||
// store: Store(
|
||
// initialState: SettingFeature.State()
|
||
// ) {
|
||
// SettingFeature()
|
||
// }
|
||
// )
|
||
//}
|