新增门店订单与核销管理列表,对齐 Android 订单能力并完善账号级缓存。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
/// 当前账号的基础资料实体,用于跨页面展示昵称、手机号和头像。
|
||||
struct AccountProfile: Codable, Equatable {
|
||||
@ -61,14 +62,24 @@ struct BusinessScope: Codable, Equatable, Identifiable {
|
||||
/// 账号上下文状态中心,保存当前账号资料和景区/门店作用域。
|
||||
final class AccountContext: ObservableObject {
|
||||
@Published private(set) var profile: AccountProfile?
|
||||
@Published private(set) var accountType: String?
|
||||
@Published private(set) var scenicScopes: [BusinessScope] = []
|
||||
@Published private(set) var storeScopes: [BusinessScope] = []
|
||||
@Published var currentScenic: BusinessScope?
|
||||
@Published var currentStore: BusinessScope?
|
||||
|
||||
/// 当前账号缓存前缀,与 Android 的账号级缓存作用域保持一致。
|
||||
var accountCachePrefix: String? {
|
||||
let userId = profile?.userId.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
guard !userId.isEmpty else { return nil }
|
||||
let type = accountType?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
return type.isEmpty ? userId : "\(type)_\(userId)"
|
||||
}
|
||||
|
||||
/// 应用登录成功后写入账号资料。
|
||||
func applyLogin(profile: AccountProfile? = nil) {
|
||||
func applyLogin(profile: AccountProfile? = nil, accountType: String? = nil) {
|
||||
self.profile = profile
|
||||
self.accountType = accountType?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
/// 替换当前账号资料,通常用于用户信息刷新后同步全局展示。
|
||||
@ -122,6 +133,7 @@ final class AccountContext: ObservableObject {
|
||||
/// 清空账号上下文,通常在退出登录时调用。
|
||||
func reset() {
|
||||
profile = nil
|
||||
accountType = nil
|
||||
scenicScopes = []
|
||||
storeScopes = []
|
||||
currentScenic = nil
|
||||
|
||||
Reference in New Issue
Block a user