修复账号切换后「我的」页当前账号展示错误,并统一举报摄影师首页 URI。
切换账号时以用户选中账号为准写入展示标题与业务作用域,避免沿用旧门店名称;同时将首页举报摄影师入口 URI 对齐为 report_photographer。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -26,7 +26,8 @@ struct AccountContextLoader {
|
||||
cachedCurrentRoleCode: String? = nil,
|
||||
cachedLegacyRoleId: Int? = nil,
|
||||
cachedCurrentScenicId: Int? = nil,
|
||||
cachedCurrentStoreId: Int? = nil
|
||||
cachedCurrentStoreId: Int? = nil,
|
||||
explicitScopeSelection: Bool = false
|
||||
) async throws {
|
||||
try await restorePermissions(
|
||||
permissionContext: permissionContext,
|
||||
@ -35,7 +36,8 @@ struct AccountContextLoader {
|
||||
cachedCurrentRoleCode: cachedCurrentRoleCode,
|
||||
cachedLegacyRoleId: cachedLegacyRoleId,
|
||||
cachedCurrentScenicId: cachedCurrentScenicId,
|
||||
cachedCurrentStoreId: cachedCurrentStoreId
|
||||
cachedCurrentStoreId: cachedCurrentStoreId,
|
||||
explicitScopeSelection: explicitScopeSelection
|
||||
)
|
||||
try await refreshSupplementalContext(
|
||||
accountContext: accountContext,
|
||||
@ -43,7 +45,8 @@ struct AccountContextLoader {
|
||||
profileAPI: profileAPI,
|
||||
accountContextAPI: accountContextAPI,
|
||||
cachedCurrentScenicId: cachedCurrentScenicId,
|
||||
cachedCurrentStoreId: cachedCurrentStoreId
|
||||
cachedCurrentStoreId: cachedCurrentStoreId,
|
||||
explicitScopeSelection: explicitScopeSelection
|
||||
)
|
||||
}
|
||||
|
||||
@ -55,7 +58,8 @@ struct AccountContextLoader {
|
||||
cachedCurrentRoleCode: String? = nil,
|
||||
cachedLegacyRoleId: Int? = nil,
|
||||
cachedCurrentScenicId: Int? = nil,
|
||||
cachedCurrentStoreId: Int? = nil
|
||||
cachedCurrentStoreId: Int? = nil,
|
||||
explicitScopeSelection: Bool = false
|
||||
) async throws {
|
||||
let rolePermissions = try await accountContextAPI.rolePermissions()
|
||||
permissionContext.replaceRolePermissions(
|
||||
@ -70,7 +74,8 @@ struct AccountContextLoader {
|
||||
scenic: roleScenicScopes,
|
||||
stores: accountContext.storeScopes,
|
||||
currentScenicId: cachedCurrentScenicId,
|
||||
currentStoreId: cachedCurrentStoreId
|
||||
currentStoreId: cachedCurrentStoreId,
|
||||
explicitSelection: explicitScopeSelection
|
||||
)
|
||||
}
|
||||
|
||||
@ -81,7 +86,8 @@ struct AccountContextLoader {
|
||||
profileAPI: UserProfileServing,
|
||||
accountContextAPI: AccountContextServing,
|
||||
cachedCurrentScenicId: Int? = nil,
|
||||
cachedCurrentStoreId: Int? = nil
|
||||
cachedCurrentStoreId: Int? = nil,
|
||||
explicitScopeSelection: Bool = false
|
||||
) async throws {
|
||||
let userInfo = try await profileAPI.userInfo()
|
||||
let scenicResponse = await loadScenicList(
|
||||
@ -94,19 +100,57 @@ struct AccountContextLoader {
|
||||
permissionContext: permissionContext,
|
||||
scenicResponse: scenicResponse
|
||||
)
|
||||
let storeScopes = storesResponse?.list.map { store in
|
||||
let fetchedStoreScopes = storesResponse?.list.map { store in
|
||||
BusinessScope(id: store.id, name: store.name, kind: .store, parentScenicId: store.scenicId)
|
||||
} ?? []
|
||||
// 门店列表接口失败或为空时,保留登录/切换时已写入的门店作用域,避免门店账号展示回退成景区名。
|
||||
let storeScopes = fetchedStoreScopes.isEmpty ? accountContext.storeScopes : fetchedStoreScopes
|
||||
|
||||
accountContext.replaceProfile(profile)
|
||||
accountContext.replaceScopes(
|
||||
scenic: scenicScopes,
|
||||
stores: storeScopes,
|
||||
currentScenicId: cachedCurrentScenicId ?? accountContext.currentScenic?.id,
|
||||
currentStoreId: cachedCurrentStoreId ?? accountContext.currentStore?.id
|
||||
currentScenicId: resolvedScenicId(
|
||||
cachedCurrentScenicId: cachedCurrentScenicId,
|
||||
accountContext: accountContext,
|
||||
explicitScopeSelection: explicitScopeSelection
|
||||
),
|
||||
currentStoreId: resolvedStoreId(
|
||||
cachedCurrentStoreId: cachedCurrentStoreId,
|
||||
accountContext: accountContext,
|
||||
explicitScopeSelection: explicitScopeSelection
|
||||
),
|
||||
explicitSelection: explicitScopeSelection
|
||||
)
|
||||
}
|
||||
|
||||
/// 解析刷新时应使用的景区 ID。
|
||||
private func resolvedScenicId(
|
||||
cachedCurrentScenicId: Int?,
|
||||
accountContext: AccountContext,
|
||||
explicitScopeSelection: Bool
|
||||
) -> Int? {
|
||||
if explicitScopeSelection {
|
||||
return cachedCurrentScenicId ?? accountContext.currentScenic?.id
|
||||
}
|
||||
return cachedCurrentScenicId ?? accountContext.currentScenic?.id
|
||||
}
|
||||
|
||||
/// 解析刷新时应使用的门店 ID;景区账号在显式选择模式下必须清空门店。
|
||||
private func resolvedStoreId(
|
||||
cachedCurrentStoreId: Int?,
|
||||
accountContext: AccountContext,
|
||||
explicitScopeSelection: Bool
|
||||
) -> Int? {
|
||||
if explicitScopeSelection {
|
||||
if accountContext.accountType == V9ScenicUser.accountTypeValue {
|
||||
return nil
|
||||
}
|
||||
return cachedCurrentStoreId
|
||||
}
|
||||
return cachedCurrentStoreId ?? accountContext.currentStore?.id
|
||||
}
|
||||
|
||||
/// 景区列表接口失败时,从角色权限中的景区数据去重构造兜底列表。
|
||||
private func loadScenicList(
|
||||
accountContextAPI: AccountContextServing,
|
||||
|
||||
Reference in New Issue
Block a user