优化冷启动流程:Launch Screen 对齐 Splash,仅阻塞 rolePermissions。
移除 SplashCoordinator,bootstrap 期间用 SplashView 覆盖避免空白闪屏,其余账号数据改为后台补充刷新。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -43,21 +43,26 @@ final class SuixinkanApp {
|
||||
hasLaunched = true
|
||||
}
|
||||
dismissSystemAlertsIfNeeded()
|
||||
waitForSplashToDisappearIfNeeded()
|
||||
waitForInitialScreen()
|
||||
if waitForLoading {
|
||||
waitForGlobalLoadingToDisappear()
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
/// 等待启动页消失后再继续后续断言。
|
||||
func waitForSplashToDisappearIfNeeded(timeout: TimeInterval = 5) {
|
||||
let splash = application.otherElements["splash.root"]
|
||||
guard splash.waitForExistence(timeout: 2) else { return }
|
||||
/// 等待冷启动后进入登录页或主 Tab。
|
||||
func waitForInitialScreen(timeout: TimeInterval = 45) {
|
||||
if application.staticTexts["login.title"].waitForExistence(timeout: 2) {
|
||||
return
|
||||
}
|
||||
|
||||
let predicate = NSPredicate(format: "exists == false")
|
||||
let expectation = XCTNSPredicateExpectation(predicate: predicate, object: splash)
|
||||
_ = XCTWaiter.wait(for: [expectation], timeout: timeout)
|
||||
let deadline = Date().addingTimeInterval(timeout)
|
||||
while Date() < deadline {
|
||||
if isOnMainTabs {
|
||||
return
|
||||
}
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.2))
|
||||
}
|
||||
}
|
||||
|
||||
/// 等待全局 Loading 层消失。
|
||||
@ -91,19 +96,4 @@ final class SuixinkanApp {
|
||||
var isOnMainTabs: Bool {
|
||||
TabBarNavigator.isVisible(in: self)
|
||||
}
|
||||
|
||||
/// 等待冷启动后进入登录页或主 Tab。
|
||||
func waitForInitialScreen(timeout: TimeInterval = 45) {
|
||||
if application.staticTexts["login.title"].waitForExistence(timeout: 2) {
|
||||
return
|
||||
}
|
||||
|
||||
let deadline = Date().addingTimeInterval(timeout)
|
||||
while Date() < deadline {
|
||||
if isOnMainTabs {
|
||||
return
|
||||
}
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.2))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user