feat: 控制第一个盲盒生成

This commit is contained in:
Junhui Chen 2025-09-12 15:20:56 +08:00
parent 5b9413699f
commit 3dc171aefe
4 changed files with 36 additions and 29 deletions

View File

@ -11,7 +11,7 @@ enum AppRoute: Hashable {
case blindOutcome(media: MediaType, title: String? = nil, description: String? = nil, isMember: Bool, goToFeedback: Bool = false)
case memories
case subscribe
case userInfo
case userInfo(createFirstBlindBox: Bool = false)
case account
case about
case permissionManagement
@ -51,8 +51,8 @@ enum AppRoute: Hashable {
MemoriesView()
case .subscribe:
SubscribeView()
case .userInfo:
UserInfo()
case .userInfo(let createFirstBlindBox):
UserInfo(createFirstBlindBox: createFirstBlindBox)
case .account:
AccountView()
case .about:

View File

@ -98,7 +98,7 @@ struct UserProfileModal: View {
}
}
.onTapGesture {
Router.shared.navigate(to: .userInfo)
Router.shared.navigate(to: .userInfo(createFirstBlindBox: false))
}
} else {
Image(systemName: "person.circle.fill")

View File

@ -264,7 +264,7 @@ struct LoginView: View {
self.showError = true
}
// userinfo
Router.shared.navigate(to: .userInfo)
Router.shared.navigate(to: .userInfo(createFirstBlindBox: true))
case .failure(let error):
print("❌ [15] 后端认证失败")

View File

@ -1,6 +1,8 @@
import SwiftUI
struct UserInfo: View {
let createFirstBlindBox: Bool
@Environment(\.dismiss) private var dismiss
@StateObject private var router = Router.shared
@ -44,9 +46,10 @@ struct UserInfo: View {
.map { _ in false })
.receive(on: RunLoop.main)
init() {
init(createFirstBlindBox: Bool) {
//
_ = UserInfo.keyboardPreloader
self.createFirstBlindBox = createFirstBlindBox
}
var body: some View {
@ -182,6 +185,7 @@ struct UserInfo: View {
self.userName = userData.username
}
if createFirstBlindBox {
//
MaterialUpload.shared.addMaterial(
fileId: uploadedFileId ?? "",
@ -208,6 +212,9 @@ struct UserInfo: View {
print("素材添加失败: \(error.localizedDescription)")
}
}
} else {
Router.shared.navigate(to: .blindBox(mediaType: .all))
}
case .failure(let error):
print("❌ 用户信息更新失败: \(error.localizedDescription)")
self.errorMessage = "更新失败: \(error.localizedDescription)"
@ -327,6 +334,6 @@ struct SettingsRow: View {
// MARK: - Preview
struct UserInfo_Previews: PreviewProvider {
static var previews: some View {
UserInfo()
UserInfo(createFirstBlindBox: false)
}
}