修复账号切换后「我的」页当前账号展示错误,并统一举报摄影师首页 URI。

切换账号时以用户选中账号为准写入展示标题与业务作用域,避免沿用旧门店名称;同时将首页举报摄影师入口 URI 对齐为 report_photographer。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-01 17:21:04 +08:00
parent fcb86d43f5
commit 5ab9b1b324
23 changed files with 419 additions and 92 deletions

View File

@ -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,