移除 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 }
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ Splash 模块负责冷启动时的品牌启动页展示,对齐 Android `Splash
|
||||
## 核心对象
|
||||
|
||||
- `SplashView`:展示白底、180pt Logo、「随心瞰 / 商家版」文案。
|
||||
- `SplashCoordinator`:并行执行最短 1.5 秒展示与 `SessionBootstrapper.restore`,两者都完成后结束 Splash。
|
||||
- `SplashCoordinator`:并行执行 `SessionBootstrapper.restore`,bootstrap 完成后结束 Splash(无固定最短展示时长)。
|
||||
- `SplashLogo` / `LaunchBackground`:启动页图片与背景色资源,同时用于系统 `UILaunchScreen`。
|
||||
|
||||
## 展示规则
|
||||
@ -23,10 +23,8 @@ Splash 模块负责冷启动时的品牌启动页展示,对齐 Android `Splash
|
||||
|
||||
1. iOS 系统 Launch Screen 展示白底 + Logo。
|
||||
2. `RootView` 挂载后立即显示 `SplashView`。
|
||||
3. `SplashCoordinator.start` 并行执行:
|
||||
- 最短展示 1.5 秒(UI Test 模式跳过)
|
||||
- `SessionBootstrapper.restore` 静默恢复登录态
|
||||
4. 两者都完成后淡出 Splash,进入 `LoginView` 或 `MainTabsView`。
|
||||
3. `SplashCoordinator.start` 并行执行 `SessionBootstrapper.restore` 静默恢复登录态。
|
||||
4. bootstrap 完成后淡出 Splash,进入 `LoginView` 或 `MainTabsView`。
|
||||
5. 冷启动期间不显示 Lottie 全局 Loading。
|
||||
|
||||
## 与 Android 的差异
|
||||
|
||||
Reference in New Issue
Block a user