接入友盟统计与 U-APM,并优化宣传页打卡点标签交互。
友盟 SDK 改为隐私同意后再初始化;宣传页标签新增滑块位移动画,超过 5 个时选中项自动滚动居中。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -51,12 +51,14 @@ struct RootView: View {
|
||||
@State private var sessionBootstrapper: SessionBootstrapper
|
||||
@State private var isColdStartBootstrapPending = true
|
||||
@State private var appConfigAPI: AppConfigAPI
|
||||
@State private var preferencesStore: AppPreferencesStore
|
||||
|
||||
/// 初始化网络客户端和业务 API,确保它们共享同一个 token provider。
|
||||
init() {
|
||||
let apiClient = APIClient()
|
||||
let tokenStore = SessionTokenStore()
|
||||
let snapshotStore = AccountSnapshotStore()
|
||||
let preferencesStore = AppPreferencesStore()
|
||||
_snapshotStore = State(initialValue: snapshotStore)
|
||||
_apiClient = State(initialValue: apiClient)
|
||||
_authAPI = State(initialValue: AuthAPI(client: apiClient))
|
||||
@ -89,11 +91,17 @@ struct RootView: View {
|
||||
_locationReportAPI = State(initialValue: locationReportAPI)
|
||||
_homeLocationViewModel = StateObject(wrappedValue: HomeLocationViewModel(api: locationReportAPI))
|
||||
_cooperationOrderAPI = State(initialValue: CooperationOrderAPI(client: apiClient))
|
||||
_preferencesStore = State(initialValue: preferencesStore)
|
||||
_authSessionCoordinator = State(
|
||||
initialValue: AuthSessionCoordinator(
|
||||
tokenStore: tokenStore,
|
||||
snapshotStore: snapshotStore,
|
||||
preferencesStore: AppPreferencesStore()
|
||||
preferencesStore: preferencesStore,
|
||||
onPrivacyAgreementPersisted: { accepted in
|
||||
guard accepted else { return }
|
||||
AMapBootstrap.configure(apiKey: AMapConfig.apiKey)
|
||||
UMengSDKBootstrap.shared.configureIfAllowed(preferencesStore: preferencesStore)
|
||||
}
|
||||
)
|
||||
)
|
||||
_sessionBootstrapper = State(
|
||||
@ -157,6 +165,7 @@ struct RootView: View {
|
||||
.environment(\.authSessionCoordinator, authSessionCoordinator)
|
||||
.task {
|
||||
apiClient.bindAuthTokenProvider { appSession.token }
|
||||
configurePrivacyGatedThirdPartySDKsIfAllowed()
|
||||
PushNotificationManager.shared.configure(api: pushAPI, session: appSession, router: appRouter)
|
||||
await sessionBootstrapper.restore(
|
||||
appSession: appSession,
|
||||
@ -256,6 +265,14 @@ struct RootView: View {
|
||||
}
|
||||
return "\(phaseText)-\(accountContext.currentScenic?.id ?? 0)"
|
||||
}
|
||||
|
||||
/// 在用户已经同意隐私政策后初始化第三方 SDK。
|
||||
private func configurePrivacyGatedThirdPartySDKsIfAllowed() {
|
||||
guard preferencesStore.loadPrivacyAgreementAccepted() else { return }
|
||||
|
||||
AMapBootstrap.configure(apiKey: AMapConfig.apiKey)
|
||||
UMengSDKBootstrap.shared.configureIfAllowed(preferencesStore: preferencesStore)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
||||
Reference in New Issue
Block a user