优化冷启动流程:Launch Screen 对齐 Splash,仅阻塞 rolePermissions。
移除 SplashCoordinator,bootstrap 期间用 SplashView 覆盖避免空白闪屏,其余账号数据改为后台补充刷新。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -48,7 +48,7 @@ struct RootView: View {
|
||||
@State private var cooperationOrderAPI: CooperationOrderAPI
|
||||
@State private var authSessionCoordinator: AuthSessionCoordinator
|
||||
@State private var sessionBootstrapper: SessionBootstrapper
|
||||
@StateObject private var splashCoordinator = SplashCoordinator()
|
||||
@State private var isColdStartBootstrapPending = true
|
||||
@State private var appConfigAPI: AppConfigAPI
|
||||
|
||||
/// 初始化网络客户端和业务 API,确保它们共享同一个 token provider。
|
||||
@ -106,7 +106,7 @@ struct RootView: View {
|
||||
ZStack {
|
||||
rootContent
|
||||
|
||||
if !splashCoordinator.isFinished {
|
||||
if isColdStartBootstrapPending {
|
||||
SplashView()
|
||||
.transition(.opacity)
|
||||
.zIndex(1)
|
||||
@ -155,15 +155,16 @@ struct RootView: View {
|
||||
.task {
|
||||
apiClient.bindAuthTokenProvider { appSession.token }
|
||||
PushNotificationManager.shared.configure(api: pushAPI, session: appSession, router: appRouter)
|
||||
await splashCoordinator.start {
|
||||
await sessionBootstrapper.restore(
|
||||
appSession: appSession,
|
||||
accountContext: accountContext,
|
||||
permissionContext: permissionContext,
|
||||
profileAPI: profileAPI,
|
||||
accountContextAPI: accountContextAPI,
|
||||
toastCenter: toastCenter
|
||||
)
|
||||
await sessionBootstrapper.restore(
|
||||
appSession: appSession,
|
||||
accountContext: accountContext,
|
||||
permissionContext: permissionContext,
|
||||
profileAPI: profileAPI,
|
||||
accountContextAPI: accountContextAPI,
|
||||
toastCenter: toastCenter
|
||||
)
|
||||
withAnimation {
|
||||
isColdStartBootstrapPending = false
|
||||
}
|
||||
if appSession.isLoggedIn, !AppUITestLaunchState.isRunningUITests {
|
||||
PushNotificationManager.shared.requestAuthorizationAndRegister()
|
||||
@ -227,7 +228,7 @@ struct RootView: View {
|
||||
case .loggedOut:
|
||||
LoginView()
|
||||
case .restoring:
|
||||
Color(.systemBackground)
|
||||
Color.clear
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
case .loggedIn:
|
||||
MainTabsView()
|
||||
|
||||
Reference in New Issue
Block a user