feat: 实现数据迁移和用户信息管理优化

- 在AppDelegate中集成数据迁移管理器,支持从UserDefaults迁移到Keychain。
- 重构UserInfoManager,使用Keychain存储用户信息,增加内存缓存以提升性能。
- 添加API加载效果视图,增强用户体验。
- 更新SplashFeature以支持自动登录和认证状态检查。
- 语言设置迁移至Keychain,确保用户设置的安全性。
This commit is contained in:
edwinQQQ
2025-07-10 17:20:20 +08:00
parent 6084ade9ea
commit 4a1b814902
15 changed files with 1773 additions and 354 deletions

View File

@@ -24,36 +24,50 @@ struct AppRootView: View {
}
var body: some View {
Group {
if shouldShowHomePage {
//
HomeView(store: homeStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
} else if shouldShowMainApp {
//
LoginView(store: loginStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
} else {
//
SplashView(store: splashStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
.onReceive(NotificationCenter.default.publisher(for: .splashFinished)) { _ in
shouldShowMainApp = true
}
ZStack {
Group {
if shouldShowHomePage {
//
HomeView(store: homeStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
} else if shouldShowMainApp {
//
LoginView(store: loginStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
} else {
//
SplashView(store: splashStore)
.transition(.opacity.animation(.easeInOut(duration: 0.5)))
}
}
}
.onReceive(NotificationCenter.default.publisher(for: .ticketSuccess)) { _ in
// Ticket
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowHomePage = true
.onReceive(NotificationCenter.default.publisher(for: .autoLoginSuccess)) { _ in
//
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowHomePage = true
}
}
}
.onReceive(NotificationCenter.default.publisher(for: .homeLogout)) { _ in
//
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowHomePage = false
shouldShowMainApp = true
.onReceive(NotificationCenter.default.publisher(for: .autoLoginFailed)) { _ in
//
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowMainApp = true
}
}
.onReceive(NotificationCenter.default.publisher(for: .ticketSuccess)) { _ in
//
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowHomePage = true
}
}
.onReceive(NotificationCenter.default.publisher(for: .homeLogout)) { _ in
//
withAnimation(.easeInOut(duration: 0.5)) {
shouldShowHomePage = false
shouldShowMainApp = true
}
}
// API Loading -
APILoadingEffectView()
}
}
}
@@ -61,6 +75,8 @@ struct AppRootView: View {
extension Notification.Name {
static let splashFinished = Notification.Name("splashFinished")
static let ticketSuccess = Notification.Name("ticketSuccess")
static let autoLoginSuccess = Notification.Name("autoLoginSuccess")
static let autoLoginFailed = Notification.Name("autoLoginFailed")
}
#Preview {