同步 Android 启动页到 iOS,并在冷启动期间静默恢复登录态。
新增 SplashView、SplashCoordinator 与 Launch Screen 资源,移除冷启动 Lottie;LoginView 加载 App 配置。同时将 token 存储迁移至 UserDefaults,并更新相关测试与文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -47,6 +47,8 @@ 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 appConfigAPI: AppConfigAPI
|
||||
|
||||
/// 初始化网络客户端和业务 API,确保它们共享同一个 token provider。
|
||||
init() {
|
||||
@ -56,6 +58,7 @@ struct RootView: View {
|
||||
_snapshotStore = State(initialValue: snapshotStore)
|
||||
_apiClient = State(initialValue: apiClient)
|
||||
_authAPI = State(initialValue: AuthAPI(client: apiClient))
|
||||
_appConfigAPI = State(initialValue: AppConfigAPI(client: apiClient))
|
||||
_profileAPI = State(initialValue: ProfileAPI(client: apiClient))
|
||||
let uploadAPI = UploadAPI(client: apiClient)
|
||||
_uploadAPI = State(initialValue: uploadAPI)
|
||||
@ -97,7 +100,15 @@ struct RootView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
rootContent
|
||||
ZStack {
|
||||
rootContent
|
||||
|
||||
if !splashCoordinator.isFinished {
|
||||
SplashView()
|
||||
.transition(.opacity)
|
||||
.zIndex(1)
|
||||
}
|
||||
}
|
||||
.globalToastOverlay()
|
||||
.globalLoadingOverlay(loadingCenter: globalLoading)
|
||||
.environmentObject(appSession)
|
||||
@ -110,6 +121,7 @@ struct RootView: View {
|
||||
.environment(\.accountSnapshotStore, snapshotStore)
|
||||
.environment(\.apiClient, apiClient)
|
||||
.environment(\.authAPI, authAPI)
|
||||
.environment(\.appConfigAPI, appConfigAPI)
|
||||
.environment(\.profileAPI, profileAPI)
|
||||
.environment(\.uploadAPI, uploadAPI)
|
||||
.environment(\.ossUploadService, ossUploadService)
|
||||
@ -139,7 +151,7 @@ struct RootView: View {
|
||||
.task {
|
||||
apiClient.bindAuthTokenProvider { appSession.token }
|
||||
PushNotificationManager.shared.configure(api: pushAPI, session: appSession, router: appRouter)
|
||||
await globalLoading.withLoading {
|
||||
await splashCoordinator.start {
|
||||
await sessionBootstrapper.restore(
|
||||
appSession: appSession,
|
||||
accountContext: accountContext,
|
||||
|
||||
Reference in New Issue
Block a user