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 } } } } } } } }