Files
e-party-iOS/yana/Views/AppRootView.swift
edwinQQQ 428aa95c5e feat: 更新Swift助手样式规则和应用结构
- 在swift-assistant-style.mdc中添加项目背景、代码结构、命名规范、Swift最佳实践、UI开发、性能、安全性、测试与质量、核心功能、开发流程、App Store指南等详细规则。
- 在yanaApp.swift中将SplashView替换为Splash,简化应用结构。
2025-08-06 14:12:20 +08:00

64 lines
2.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
import ComposableArchitecture
struct AppRootView: View {
@State private var isLoggedIn = false
@State private var mainStore: StoreOf<MainFeature>?
var body: some View {
Group {
if isLoggedIn {
if let mainStore = mainStore {
MainView(store: mainStore)
.onAppear {
debugInfoSync("🔄 AppRootView: 使用已存在的MainStore")
}
} else {
// store
let store = createMainStore()
MainView(store: store)
.onAppear {
debugInfoSync("💾 AppRootView: MainStore已创建并保存")
// onAppearstore
DispatchQueue.main.async {
self.mainStore = store
}
}
}
} else {
LoginView(
store: Store(
initialState: LoginFeature.State()
) {
LoginFeature()
},
onLoginSuccess: {
debugInfoSync("🔐 AppRootView: 登录成功准备创建MainStore")
isLoggedIn = true
// store
mainStore = createMainStore()
}
)
}
}
.onAppear {
debugInfoSync("🚀 AppRootView onAppear")
debugInfoSync(" isLoggedIn: \(isLoggedIn)")
debugInfoSync(" mainStore存在: \(mainStore != nil)")
}
}
private func createMainStore() -> StoreOf<MainFeature> {
debugInfoSync("🏗️ AppRootView: 创建新的MainStore实例")
return Store(
initialState: MainFeature.State()
) {
MainFeature()
}
}
}
//
//#Preview {
// AppRootView()
//}