模块化 AppStore 并完善素材管理与个人空间设置。
将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -25,42 +25,42 @@ final class ProfileViewModel {
|
||||
}
|
||||
|
||||
var displayPhone: String {
|
||||
nonEmpty(userInfo?.phone) ?? AppStore.shared.phone.nonEmpty ?? "--"
|
||||
nonEmpty(userInfo?.phone) ?? AppStore.shared.session.phone.nonEmpty ?? "--"
|
||||
}
|
||||
|
||||
var displayAvatarURL: String {
|
||||
nonEmpty(userInfo?.avatar) ?? AppStore.shared.avatar.nonEmpty ?? ""
|
||||
nonEmpty(userInfo?.avatar) ?? AppStore.shared.session.avatar.nonEmpty ?? ""
|
||||
}
|
||||
|
||||
var displayUID: String {
|
||||
let uid = AppStore.shared.userId.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let uid = AppStore.shared.session.userId.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return uid.isEmpty ? "--" : uid
|
||||
}
|
||||
|
||||
var accountDisplayName: String {
|
||||
let name = AppStore.shared.accountDisplayName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let name = AppStore.shared.session.accountDisplayName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return name.isEmpty ? "--" : name
|
||||
}
|
||||
|
||||
/// 当前账号类型文案,如「门店账号」「景区账号」。
|
||||
var accountTypeLabel: String {
|
||||
let type = AppStore.shared.accountType.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if type == V9StoreUser.accountTypeValue {
|
||||
return "门店账号"
|
||||
switch AppStore.shared.session.accountType {
|
||||
case .storeUser:
|
||||
"门店账号"
|
||||
case .scenicUser:
|
||||
"景区账号"
|
||||
case .unknown:
|
||||
"--"
|
||||
}
|
||||
if type == V9ScenicUser.accountTypeValue {
|
||||
return "景区账号"
|
||||
}
|
||||
return "--"
|
||||
}
|
||||
|
||||
/// 当前是否为门店账号。
|
||||
var isStoreAccount: Bool {
|
||||
AppStore.shared.accountType == V9StoreUser.accountTypeValue
|
||||
AppStore.shared.session.accountType == .storeUser
|
||||
}
|
||||
|
||||
var currentScenicName: String {
|
||||
let name = AppStore.shared.currentScenicName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let name = AppStore.shared.session.currentScenicName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return name.isEmpty ? "--" : name
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ final class ProfileViewModel {
|
||||
}
|
||||
|
||||
var showPhotographerFields: Bool {
|
||||
if AppStore.shared.isPhotographerRole {
|
||||
if AppStore.shared.session.isPhotographerRole {
|
||||
return true
|
||||
}
|
||||
if let roleName = nonEmpty(userInfo?.roleName) {
|
||||
@ -108,9 +108,9 @@ final class ProfileViewModel {
|
||||
|
||||
let info = try await api.userInfo()
|
||||
userInfo = info
|
||||
AppStore.shared.applyUserInfo(info)
|
||||
AppStore.shared.session.applyUserInfo(info)
|
||||
if !info.roleName.isEmpty {
|
||||
AppStore.shared.roleName = info.roleName
|
||||
AppStore.shared.session.roleName = info.roleName
|
||||
}
|
||||
|
||||
if showPhotographerFields {
|
||||
@ -128,8 +128,8 @@ final class ProfileViewModel {
|
||||
/// 从 `AppStore` 同步头像与昵称,用于资料保存后的本地即时刷新。
|
||||
func applyLocalProfileUpdate(from store: AppStore = .shared) {
|
||||
let previous = userInfo ?? UserInfoResponse()
|
||||
let nextNickname = store.userName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let nextAvatar = store.avatar.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let nextNickname = store.session.userName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let nextAvatar = store.session.avatar.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
userInfo = UserInfoResponse(
|
||||
avatar: nextAvatar.isEmpty ? previous.avatar : nextAvatar,
|
||||
realName: previous.realName,
|
||||
|
||||
Reference in New Issue
Block a user