移除 Splash 固定 1.5 秒等待,并补充启动流程分析文档。
未登录冷启动可立即进入登录页;已登录仍等待 bootstrap 接口完成,但不再叠加人为延迟。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -26,11 +26,13 @@ App 模块负责应用入口、根视图切换、全局状态注入、主导航
|
||||
|
||||
## 启动流程
|
||||
|
||||
> 完整启动接口清单、数据依赖与 Splash 优化方案见 [启动流程分析与优化方案](../../docs/startup-analysis.md)。
|
||||
|
||||
1. `suixinkanApp` 创建 `RootView`。
|
||||
2. `RootView` 初始化共享依赖,并把它们注入 Environment。
|
||||
3. iOS 系统 Launch Screen 展示白底 + `SplashLogo`。
|
||||
4. `SplashView` 覆盖根视图,展示与 Android 对齐的品牌启动页。
|
||||
5. `SplashCoordinator.start` 并行执行最短 1.5 秒展示和 `SessionBootstrapper.restore`;UI Test 模式跳过 1.5 秒延迟。
|
||||
5. `SplashCoordinator.start` 并行执行 `SessionBootstrapper.restore`;Splash 以 bootstrap 完成为准,无固定最短展示时长。
|
||||
6. `APIClient` 绑定 `AppSession.token` 作为默认 token provider。
|
||||
7. `SessionBootstrapper.restore` 尝试从 UserDefaults 读取正式 token。
|
||||
8. 无 token 时保持 `loggedOut`,Splash 结束后展示 `LoginView`。
|
||||
|
||||
@ -9,23 +9,23 @@ import Combine
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
/// 启动页时序协调器,保证品牌页最短展示时长与冷启动 bootstrap 并行完成。
|
||||
/// 启动页时序协调器,并行执行冷启动 bootstrap,Splash 结束时机以 bootstrap 完成为准。
|
||||
final class SplashCoordinator: ObservableObject {
|
||||
@Published private(set) var isFinished = false
|
||||
|
||||
private let minimumDisplayDuration: TimeInterval
|
||||
private let skipsMinimumDuration: Bool
|
||||
|
||||
/// 创建启动页协调器,并配置最短展示时长与 UI Test 跳过策略。
|
||||
/// 创建启动页协调器;默认无最短展示时长,测试可注入自定义 delay。
|
||||
init(
|
||||
minimumDisplayDuration: TimeInterval = 1.5,
|
||||
minimumDisplayDuration: TimeInterval = 0,
|
||||
skipsMinimumDuration: Bool = AppUITestLaunchState.isRunningUITests
|
||||
) {
|
||||
self.minimumDisplayDuration = minimumDisplayDuration
|
||||
self.skipsMinimumDuration = skipsMinimumDuration
|
||||
}
|
||||
|
||||
/// 并行执行 bootstrap 与最短展示时长,两者都完成后结束 Splash。
|
||||
/// 并行执行 bootstrap 与可选最短展示时长,两者都完成后结束 Splash。
|
||||
func start(bootstrap: @escaping () async -> Void) async {
|
||||
guard !isFinished else { return }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user