完善多赛道联调与全局产品架构
This commit is contained in:
@@ -30,6 +30,21 @@ export interface BackendResolvedRelease {
|
||||
routeCode?: string | null
|
||||
}
|
||||
|
||||
export interface BackendCourseVariantSummary {
|
||||
id: string
|
||||
name: string
|
||||
description?: string | null
|
||||
routeCode?: string | null
|
||||
selectable?: boolean
|
||||
}
|
||||
|
||||
export interface BackendLaunchVariantSummary {
|
||||
id: string
|
||||
name: string
|
||||
routeCode?: string | null
|
||||
assignmentMode?: string | null
|
||||
}
|
||||
|
||||
export interface BackendEntrySessionSummary {
|
||||
id: string
|
||||
status: string
|
||||
@@ -38,6 +53,8 @@ export interface BackendEntrySessionSummary {
|
||||
releaseId?: string | null
|
||||
configLabel?: string | null
|
||||
routeCode?: string | null
|
||||
variantId?: string | null
|
||||
variantName?: string | null
|
||||
launchedAt?: string | null
|
||||
startedAt?: string | null
|
||||
endedAt?: string | null
|
||||
@@ -111,6 +128,8 @@ export interface BackendEventPlayResult {
|
||||
primaryAction: string
|
||||
reason: string
|
||||
launchSource?: string
|
||||
assignmentMode?: string | null
|
||||
courseVariants?: BackendCourseVariantSummary[] | null
|
||||
ongoingSession?: BackendEntrySessionSummary | null
|
||||
recentSession?: BackendEntrySessionSummary | null
|
||||
}
|
||||
@@ -139,6 +158,7 @@ export interface BackendLaunchResult {
|
||||
sessionTokenExpiresAt: string
|
||||
routeCode?: string | null
|
||||
}
|
||||
variant?: BackendLaunchVariantSummary | null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +314,7 @@ export function launchEvent(input: {
|
||||
eventId: string
|
||||
accessToken: string
|
||||
releaseId?: string
|
||||
variantId?: string
|
||||
clientType: string
|
||||
deviceKey: string
|
||||
}): Promise<BackendLaunchResult> {
|
||||
@@ -304,6 +325,9 @@ export function launchEvent(input: {
|
||||
if (input.releaseId) {
|
||||
body.releaseId = input.releaseId
|
||||
}
|
||||
if (input.variantId) {
|
||||
body.variantId = input.variantId
|
||||
}
|
||||
return requestBackend<BackendLaunchResult>({
|
||||
method: 'POST',
|
||||
baseUrl: input.baseUrl,
|
||||
|
||||
@@ -17,5 +17,17 @@ export function adaptBackendLaunchResultToEnvelope(result: BackendLaunchResult):
|
||||
sessionToken: result.launch.business.sessionToken,
|
||||
sessionTokenExpiresAt: result.launch.business.sessionTokenExpiresAt,
|
||||
},
|
||||
variant: result.launch.variant
|
||||
? {
|
||||
variantId: result.launch.variant.id,
|
||||
variantName: result.launch.variant.name,
|
||||
routeCode: result.launch.variant.routeCode || result.launch.config.routeCode || result.launch.business.routeCode || null,
|
||||
assignmentMode: result.launch.variant.assignmentMode || null,
|
||||
}
|
||||
: (result.launch.config.routeCode || result.launch.business.routeCode)
|
||||
? {
|
||||
routeCode: result.launch.config.routeCode || result.launch.business.routeCode || null,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,17 @@ export interface BusinessLaunchContext {
|
||||
realtimeToken?: string | null
|
||||
}
|
||||
|
||||
export interface GameVariantLaunchContext {
|
||||
variantId?: string | null
|
||||
variantName?: string | null
|
||||
routeCode?: string | null
|
||||
assignmentMode?: string | null
|
||||
}
|
||||
|
||||
export interface GameLaunchEnvelope {
|
||||
config: GameConfigLaunchRequest
|
||||
business: BusinessLaunchContext | null
|
||||
variant?: GameVariantLaunchContext | null
|
||||
}
|
||||
|
||||
export interface MapPageLaunchOptions {
|
||||
@@ -46,6 +54,9 @@ export interface MapPageLaunchOptions {
|
||||
sessionTokenExpiresAt?: string
|
||||
realtimeEndpoint?: string
|
||||
realtimeToken?: string
|
||||
variantId?: string
|
||||
variantName?: string
|
||||
assignmentMode?: string
|
||||
}
|
||||
|
||||
type PendingGameLaunchStore = Record<string, GameLaunchEnvelope>
|
||||
@@ -121,6 +132,28 @@ function buildBusinessLaunchContext(options?: MapPageLaunchOptions | null): Busi
|
||||
}
|
||||
}
|
||||
|
||||
function buildVariantLaunchContext(options?: MapPageLaunchOptions | null): GameVariantLaunchContext | null {
|
||||
if (!options) {
|
||||
return null
|
||||
}
|
||||
|
||||
const variantId = normalizeOptionalString(options.variantId)
|
||||
const variantName = normalizeOptionalString(options.variantName)
|
||||
const routeCode = normalizeOptionalString(options.routeCode)
|
||||
const assignmentMode = normalizeOptionalString(options.assignmentMode)
|
||||
|
||||
if (!variantId && !variantName && !routeCode && !assignmentMode) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
variantId,
|
||||
variantName,
|
||||
routeCode,
|
||||
assignmentMode,
|
||||
}
|
||||
}
|
||||
|
||||
function loadPendingGameLaunchStore(): PendingGameLaunchStore {
|
||||
try {
|
||||
const stored = wx.getStorageSync(PENDING_GAME_LAUNCH_STORAGE_KEY)
|
||||
@@ -146,6 +179,7 @@ export function getDemoGameLaunchEnvelope(preset: DemoGamePreset = 'classic'): G
|
||||
business: {
|
||||
source: 'demo',
|
||||
},
|
||||
variant: null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +251,7 @@ export function resolveGameLaunchEnvelope(options?: MapPageLaunchOptions | null)
|
||||
routeCode: normalizeOptionalString(options ? options.routeCode : undefined),
|
||||
},
|
||||
business: buildBusinessLaunchContext(options),
|
||||
variant: buildVariantLaunchContext(options),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user