Files
e-party-iOS/yana/MVVM/SplashPage.swift
edwinQQQ 07265c01db feat: 更新视图组件及数据模型
- 在yanaApp中为SplashPage添加忽略安全区域的设置,确保全屏显示。
- 在DynamicsModels中更新MyMomentInfo结构,添加可选字段以兼容不同版本的服务器返回数据。
- 在CommonComponents中将LoginBackgroundView的背景图替换为蓝色,简化视图。
- 在MainPage中为内容添加忽略安全区域的设置,提升布局一致性。
- 在MePage中新增MePageViewModel,优化用户信息管理逻辑,支持动态列表的加载和错误处理。
- 在SplashPage中调整过渡动画时长,提升用户体验。
2025-09-26 14:57:34 +08:00

63 lines
2.4 KiB
Swift

import SwiftUI
struct SplashPage: View {
@State private var showLogin = false
@State private var showMain = false
@State private var hasCheckedAuth = false
private let splashTransitionAnimation: Animation = .easeInOut(duration: 0.5)
var body: some View {
Group {
if showMain {
MainPage(onLogout: {
showMain = false
showLogin = true
})
} else if showLogin {
NavigationStack {
LoginPage(onLoginSuccess: {
showMain = true
})
}
} else {
ZStack {
LoginBackgroundView()
VStack(spacing: 32) {
Spacer().frame(height: 200)
Image("logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 100, height: 100)
Text(LocalizedString("splash.title", comment: "E-Parti"))
.font(.system(size: 40, weight: .regular))
.foregroundColor(.white)
Spacer()
}
}
.onAppear {
guard !hasCheckedAuth else { return }
hasCheckedAuth = true
Task { @MainActor in
debugInfoSync("🚀 SplashV2 启动,开始检查登录缓存")
let status = await UserInfoManager.checkAuthenticationStatus()
if status.canAutoLogin {
debugInfoSync("✅ 检测到可自动登录,尝试预取用户信息")
_ = await UserInfoManager.autoFetchUserInfoOnAppLaunch(apiService: LiveAPIService())
withAnimation(splashTransitionAnimation) {
showMain = true
}
} else {
debugInfoSync("🔑 未登录或缓存无效,进入登录页")
withAnimation(splashTransitionAnimation) {
showLogin = true
}
}
}
}
}
}
}
}