feat: 更新.gitignore,删除需求文档,优化API调试信息

- 在.gitignore中添加忽略项以排除不必要的文件。
- 删除架构分析需求文档以简化项目文档。
- 在APIEndpoints.swift和LoginModels.swift中移除调试信息的异步调用,提升代码简洁性。
- 在EMailLoginFeature.swift和HomeFeature.swift中新增登录流程状态管理,优化用户体验。
- 在多个视图中调整状态管理和导航逻辑,确保一致性和可维护性。
- 更新Xcode项目配置以增强调试信息的输出格式。
This commit is contained in:
edwinQQQ
2025-07-18 15:57:54 +08:00
parent 128bf36c88
commit fb7ae9e0ad
20 changed files with 562 additions and 720 deletions

View File

@@ -1,5 +1,6 @@
import SwiftUI
import ComposableArchitecture
import Combine
struct EMailLoginView: View {
let store: StoreOf<EMailLoginFeature>
@@ -9,7 +10,7 @@ struct EMailLoginView: View {
@State private var email: String = ""
@State private var verificationCode: String = ""
@State private var codeCountdown: Int = 0
@State private var timer: Timer?
@State private var timerCancellable: AnyCancellable?
//
@FocusState private var focusedField: Field?
@@ -41,8 +42,10 @@ struct EMailLoginView: View {
}
var body: some View {
GeometryReader { geometry in
ZStack {
// WithViewStore(store, observe: { $0 }) { _ in
GeometryReader { geometry in
WithPerceptionTracking {
ZStack {
//
Image("bg")
.resizable()
@@ -200,36 +203,48 @@ struct EMailLoginView: View {
Spacer()
}
}
}
}
// }
.onAppear {
//
store.send(.resetState)
email = ""
verificationCode = ""
codeCountdown = 0
stopCountdown()
#if DEBUG
email = "exzero@126.com"
store.send(.emailChanged(email))
#endif
let _ = WithPerceptionTracking {
//
store.send(.resetState)
email = ""
verificationCode = ""
codeCountdown = 0
stopCountdown()
#if DEBUG
email = "exzero@126.com"
store.send(.emailChanged(email))
#endif
}
}
.onDisappear {
stopCountdown()
let _ = WithPerceptionTracking {
stopCountdown()
}
}
.onChange(of: email) { newEmail in
store.send(.emailChanged(newEmail))
let _ = WithPerceptionTracking {
store.send(.emailChanged(newEmail))
}
}
.onChange(of: verificationCode) { newCode in
store.send(.verificationCodeChanged(newCode))
let _ = WithPerceptionTracking {
store.send(.verificationCodeChanged(newCode))
}
}
.onChange(of: store.isCodeLoading) { isCodeLoading in
// API
if !isCodeLoading && store.errorMessage == nil {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
focusedField = .verificationCode
let _ = WithPerceptionTracking {
// API
if !isCodeLoading && store.errorMessage == nil {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
focusedField = .verificationCode
}
}
}
}
@@ -242,30 +257,31 @@ struct EMailLoginView: View {
//
codeCountdown = 60
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
DispatchQueue.main.async {
// 使 SwiftUI Timer.publish
timerCancellable = Timer.publish(every: 1.0, on: .main, in: .common)
.autoconnect()
.sink { _ in
if codeCountdown > 0 {
codeCountdown -= 1
} else {
stopCountdown()
}
}
}
}
private func stopCountdown() {
timer?.invalidate()
timer = nil
timerCancellable?.cancel()
timerCancellable = nil
}
}
#Preview {
EMailLoginView(
store: Store(
initialState: EMailLoginFeature.State()
) {
EMailLoginFeature()
},
onBack: {}
)
}
//#Preview {
// EMailLoginView(
// store: Store(
// initialState: EMailLoginFeature.State()
// ) {
// EMailLoginFeature()
// },
// onBack: {}
// )
//}