Centralize dependency wiring with Session/Context/Network/UI/Runtime bundles, unify leaf ViewControllers on appServices, and add a test initializer with AppServicesTests. Co-authored-by: Cursor <cursoragent@cursor.com>
97 lines
3.3 KiB
Swift
97 lines
3.3 KiB
Swift
//
|
||
// AppServicesBundles.swift
|
||
// suixinkan
|
||
//
|
||
// Created by Codex on 2026/6/26.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
@MainActor
|
||
/// 登录与会话恢复相关依赖分组。
|
||
struct SessionBundle {
|
||
let appSession: AppSession
|
||
let authSessionCoordinator: AuthSessionCoordinator
|
||
let sessionBootstrapper: SessionBootstrapper
|
||
}
|
||
|
||
@MainActor
|
||
/// 账号、权限与景区景点等业务作用域 Context 分组。
|
||
struct AppContextBundle {
|
||
let accountContext: AccountContext
|
||
let permissionContext: PermissionContext
|
||
let scenicSpotContext: ScenicSpotContext
|
||
}
|
||
|
||
@MainActor
|
||
/// 网络层依赖分组,共享同一 `APIClient` 与 token 链路。
|
||
struct NetworkBundle {
|
||
let apiClient: APIClient
|
||
let authAPI: AuthAPI
|
||
let profileAPI: ProfileAPI
|
||
let uploadAPI: UploadAPI
|
||
let ossUploadService: OSSUploadService
|
||
let accountContextAPI: AccountContextAPI
|
||
let ordersAPI: OrdersAPI
|
||
let statisticsAPI: StatisticsAPI
|
||
let paymentAPI: PaymentAPI
|
||
let walletAPI: WalletAPI
|
||
let pushAPI: PushAPI
|
||
let scenicPermissionAPI: ScenicPermissionAPI
|
||
let scenicSettlementAPI: ScenicSettlementAPI
|
||
let messageCenterAPI: MessageCenterAPI
|
||
let scenicQueueAPI: ScenicQueueAPI
|
||
let liveAPI: LiveAPI
|
||
let operatingAreaAPI: OperatingAreaAPI
|
||
let pilotCertificationAPI: PilotCertificationAPI
|
||
let taskAPI: TaskAPI
|
||
let projectAPI: ProjectAPI
|
||
let scheduleAPI: ScheduleAPI
|
||
let inviteAPI: InviteAPI
|
||
let assetsAPI: AssetsAPI
|
||
let punchPointAPI: PunchPointAPI
|
||
let locationReportAPI: LocationReportAPI
|
||
|
||
/// 基于共享 `APIClient` 创建全部业务 API。
|
||
init(apiClient: APIClient) {
|
||
self.apiClient = apiClient
|
||
authAPI = AuthAPI(client: apiClient)
|
||
profileAPI = ProfileAPI(client: apiClient)
|
||
uploadAPI = UploadAPI(client: apiClient)
|
||
ossUploadService = OSSUploadService(configService: uploadAPI)
|
||
accountContextAPI = AccountContextAPI(client: apiClient)
|
||
ordersAPI = OrdersAPI(client: apiClient)
|
||
statisticsAPI = StatisticsAPI(client: apiClient)
|
||
paymentAPI = PaymentAPI(client: apiClient)
|
||
walletAPI = WalletAPI(client: apiClient)
|
||
pushAPI = PushAPI(client: apiClient)
|
||
scenicPermissionAPI = ScenicPermissionAPI(client: apiClient)
|
||
scenicSettlementAPI = ScenicSettlementAPI(client: apiClient)
|
||
messageCenterAPI = MessageCenterAPI(client: apiClient)
|
||
scenicQueueAPI = ScenicQueueAPI(client: apiClient)
|
||
liveAPI = LiveAPI(client: apiClient)
|
||
operatingAreaAPI = OperatingAreaAPI(client: apiClient)
|
||
pilotCertificationAPI = PilotCertificationAPI(client: apiClient)
|
||
taskAPI = TaskAPI(client: apiClient)
|
||
projectAPI = ProjectAPI(client: apiClient)
|
||
scheduleAPI = ScheduleAPI(client: apiClient)
|
||
inviteAPI = InviteAPI(client: apiClient)
|
||
assetsAPI = AssetsAPI(client: apiClient)
|
||
punchPointAPI = PunchPointAPI(client: apiClient)
|
||
locationReportAPI = LocationReportAPI(client: apiClient)
|
||
}
|
||
}
|
||
|
||
@MainActor
|
||
/// 全局 UI 反馈(Toast、Loading)分组。
|
||
struct UIFeedbackBundle {
|
||
let toastCenter: ToastCenter
|
||
let globalLoading: GlobalLoadingCenter
|
||
}
|
||
|
||
@MainActor
|
||
/// 与登录态联动的后台运行时依赖分组。
|
||
struct AppRuntimeBundle {
|
||
let scenicQueueRuntime: ScenicQueueRuntime
|
||
}
|