修复合作获客扫码绑定崩溃与 Toast 层级,并接入分成比例修改。
将扫码页提升到列表层弹出并补齐 AppDelegate.window,避免扫码时 UIKit 取主窗口崩溃;Toast 改用独立 UIWindow 显示在 sheet 之上;合作获客员支持短信验证修改分成比例,同时优化冷启动根视图创建时机并补充相关测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -7,6 +7,30 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// 根视图内容展示状态,隔离冷启动判定与登录阶段切换。
|
||||
enum RootContentDisplayState: Equatable {
|
||||
case bootstrapPlaceholder
|
||||
case login
|
||||
case restoringPlaceholder
|
||||
case mainTabs
|
||||
|
||||
/// 根据冷启动 bootstrap 状态和登录阶段计算当前应创建的根内容。
|
||||
static func resolve(isColdStartBootstrapPending: Bool, appPhase: AuthPhase) -> RootContentDisplayState {
|
||||
if isColdStartBootstrapPending {
|
||||
return .bootstrapPlaceholder
|
||||
}
|
||||
|
||||
switch appPhase {
|
||||
case .loggedOut:
|
||||
return .login
|
||||
case .restoring:
|
||||
return .restoringPlaceholder
|
||||
case .loggedIn:
|
||||
return .mainTabs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// App 根视图,负责创建全局依赖并根据登录状态切换登录页和主界面。
|
||||
struct RootView: View {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@ -236,13 +260,13 @@ struct RootView: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var rootContent: some View {
|
||||
switch appSession.phase {
|
||||
case .loggedOut:
|
||||
LoginView()
|
||||
case .restoring:
|
||||
switch rootContentDisplayState {
|
||||
case .bootstrapPlaceholder, .restoringPlaceholder:
|
||||
Color.clear
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
case .loggedIn:
|
||||
case .login:
|
||||
LoginView()
|
||||
case .mainTabs:
|
||||
MainTabsView()
|
||||
.task {
|
||||
#if DEBUG
|
||||
@ -252,6 +276,14 @@ struct RootView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// 计算根视图当前应创建的内容,避免冷启动期间提前创建登录页。
|
||||
private var rootContentDisplayState: RootContentDisplayState {
|
||||
RootContentDisplayState.resolve(
|
||||
isColdStartBootstrapPending: isColdStartBootstrapPending,
|
||||
appPhase: appSession.phase
|
||||
)
|
||||
}
|
||||
|
||||
/// 景点加载任务的稳定标识,确保登录状态和当前景区变化都会触发任务。
|
||||
private var scenicSpotTaskID: String {
|
||||
let phaseText: String
|
||||
|
||||
Reference in New Issue
Block a user