
- 在AppSettingFeature中实现登出逻辑,清理认证信息并发送登出事件。 - 在MainFeature中新增登出标志和相应的状态管理,确保用户登出后状态更新。 - 更新MainView以响应登出事件,重命名内部视图为InternalMainView以提高可读性。 - 在SplashView中集成登出处理,确保用户能够顺利返回登录页面。
89 lines
2.8 KiB
Swift
89 lines
2.8 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
|
||
struct SplashView: View {
|
||
let store: StoreOf<SplashFeature>
|
||
|
||
var body: some View {
|
||
WithPerceptionTracking {
|
||
Group {
|
||
// 根据导航目标显示不同页面
|
||
if let navigationDestination = store.navigationDestination {
|
||
switch navigationDestination {
|
||
case .login:
|
||
// 显示登录页面
|
||
LoginView(
|
||
store: Store(
|
||
initialState: LoginFeature.State()
|
||
) {
|
||
LoginFeature()
|
||
},
|
||
onLoginSuccess: {
|
||
// 登录成功后导航到主页面
|
||
store.send(.navigateToMain)
|
||
}
|
||
)
|
||
case .main:
|
||
// 显示主应用页面
|
||
MainView(
|
||
store: Store(
|
||
initialState: MainFeature.State()
|
||
) {
|
||
MainFeature()
|
||
},
|
||
onLogout: {
|
||
store.send(.navigateToLogin)
|
||
}
|
||
)
|
||
}
|
||
} else {
|
||
// 显示启动画面
|
||
splashContent
|
||
}
|
||
}
|
||
.onAppear {
|
||
store.send(.onAppear)
|
||
}
|
||
}
|
||
}
|
||
|
||
// 启动画面内容
|
||
private var splashContent: some View {
|
||
ZStack {
|
||
// 背景图片 - 全屏显示
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.ignoresSafeArea(.all)
|
||
|
||
VStack(spacing: 32) {
|
||
Spacer()
|
||
.frame(height: 200) // 与 storyboard 中的约束对应
|
||
|
||
// Logo 图片 - 100x100
|
||
Image("logo")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fit)
|
||
.frame(width: 100, height: 100)
|
||
|
||
// 应用标题 - 白色,40pt字体
|
||
Text(NSLocalizedString("splash.title", comment: "E-Parti"))
|
||
.font(.system(size: 40, weight: .regular))
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//#Preview {
|
||
// SplashView(
|
||
// store: Store(
|
||
// initialState: SplashFeature.State()
|
||
// ) {
|
||
// SplashFeature()
|
||
// }
|
||
// )
|
||
//}
|