feat: 增强邮箱登录功能和密码恢复流程

- 更新邮箱登录相关功能,新增邮箱验证码获取和登录API端点。
- 添加AccountModel以管理用户认证信息,支持会话票据的存储和更新。
- 实现密码恢复功能,支持通过邮箱获取验证码和重置密码。
- 增加本地化支持,更新相关字符串以适应新功能。
- 引入ValidationHelper以验证邮箱和密码格式,确保用户输入的有效性。
- 更新视图以支持邮箱登录和密码恢复的用户交互。
This commit is contained in:
edwinQQQ
2025-07-10 14:00:58 +08:00
parent c470dba79c
commit e45ad3bad5
23 changed files with 2054 additions and 164 deletions

124
yana/Views/HomeView.swift Normal file
View File

@@ -0,0 +1,124 @@
import SwiftUI
import ComposableArchitecture
struct HomeView: View {
let store: StoreOf<HomeFeature>
@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
Text("home.title".localized)
.font(.custom("PingFang SC-Semibold", size: 16))
.foregroundColor(.white)
.frame(
width: 158,
height: 22,
alignment: .center
) //
.padding(.top, 8)
.padding(.horizontal)
//
VStack(spacing: 32) {
Spacer()
//
VStack(spacing: 16) {
// UserInfo
if let userInfo = store.userInfo, let userName = userInfo.username {
Text("欢迎, \(userName)")
.font(.title2)
.foregroundColor(.white)
} else {
Text("欢迎")
.font(.title2)
.foregroundColor(.white)
}
// ID UserInfo AccountModel
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))
}
// AccountModel
if let accountModel = store.accountModel {
VStack(spacing: 4) {
if accountModel.hasValidSession {
HStack {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.green)
Text("已登录")
.foregroundColor(.white.opacity(0.9))
}
.font(.caption)
} else if accountModel.hasValidAuthentication {
HStack {
Image(systemName: "clock.circle.fill")
.foregroundColor(.orange)
Text("认证中")
.foregroundColor(.white.opacity(0.9))
}
.font(.caption)
}
}
}
}
.padding()
.background(Color.black.opacity(0.3))
.cornerRadius(12)
.padding(.horizontal, 32)
Spacer()
//
Button(action: {
store.send(.logoutTapped)
}) {
HStack {
Image(systemName: "arrow.right.square")
Text("退出登录")
}
.font(.body)
.foregroundColor(.white)
.padding(.horizontal, 24)
.padding(.vertical, 12)
.background(Color.red.opacity(0.7))
.cornerRadius(8)
}
.padding(.bottom, 50)
}
}
}
}
.onAppear {
store.send(.onAppear)
}
}
}
}
#Preview {
HomeView(
store: Store(
initialState: HomeFeature.State()
) {
HomeFeature()
}
)
}