fix: 修正账号姓名展示与资料缓存
This commit is contained in:
@ -17,11 +17,11 @@ final class ProfileViewModel {
|
||||
var onStateChange: (() -> Void)?
|
||||
|
||||
var displayNickname: String {
|
||||
nonEmpty(userInfo?.nickname) ?? "未设置昵称"
|
||||
nonEmpty(userInfo?.nickname) ?? AppStore.shared.session.userName.nonEmpty ?? "未设置昵称"
|
||||
}
|
||||
|
||||
var displayRealName: String {
|
||||
nonEmpty(userInfo?.realName) ?? "--"
|
||||
nonEmpty(userInfo?.realName) ?? AppStore.shared.session.realName.nonEmpty ?? "--"
|
||||
}
|
||||
|
||||
var displayPhone: String {
|
||||
@ -37,6 +37,17 @@ final class ProfileViewModel {
|
||||
return uid.isEmpty ? "--" : uid
|
||||
}
|
||||
|
||||
/// 本地是否已有可供冷启动首屏展示的基本资料。
|
||||
var hasCachedBasicInfo: Bool {
|
||||
[
|
||||
AppStore.shared.session.userName,
|
||||
AppStore.shared.session.realName,
|
||||
AppStore.shared.session.phone,
|
||||
AppStore.shared.session.avatar,
|
||||
AppStore.shared.session.userId,
|
||||
].contains { nonEmpty($0) != nil }
|
||||
}
|
||||
|
||||
var accountDisplayName: String {
|
||||
let name = AppStore.shared.session.accountDisplayName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return name.isEmpty ? "--" : name
|
||||
@ -112,6 +123,7 @@ final class ProfileViewModel {
|
||||
if !info.roleName.isEmpty {
|
||||
AppStore.shared.session.roleName = info.roleName
|
||||
}
|
||||
notifyStateChange()
|
||||
|
||||
if showPhotographerFields {
|
||||
async let realName = api.realNameInfo()
|
||||
|
||||
Reference in New Issue
Block a user