统一推荐页各玩法正式 runtime 的游客鉴权透传。 收口推荐页首页展示队列和嵌入运行态切换队列。 补齐未登录读档、签名资产和个人数据读取的游客态处理。 新增运行态 HUD 小尺寸 logo 资源并更新拼图与抓鹅展示。 补充推荐切换、runtime guest 启动和客户端请求回归测试。 更新玩法链路、后端契约和团队记忆文档。
86 lines
2.4 KiB
TypeScript
86 lines
2.4 KiB
TypeScript
import type {
|
|
BigFishRunResponse,
|
|
RecordBigFishPlayRequest,
|
|
SubmitBigFishInputRequest,
|
|
} from '../../../packages/shared/src/contracts/bigFish';
|
|
import type { BigFishWorksResponse } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
|
|
import { type ApiRetryOptions } from '../apiClient';
|
|
import { type RuntimeGuestRequestOptions } from '../runtimeGuestAuth';
|
|
import { buildRuntimeApiPath, requestRuntimeJson } from '../runtimeRequest';
|
|
|
|
const BIG_FISH_RUNTIME_API_BASE = '/api/runtime/big-fish';
|
|
const BIG_FISH_RUNTIME_WRITE_RETRY: ApiRetryOptions = {
|
|
maxRetries: 1,
|
|
baseDelayMs: 120,
|
|
maxDelayMs: 360,
|
|
retryUnsafeMethods: true,
|
|
};
|
|
type BigFishRuntimeRequestOptions = RuntimeGuestRequestOptions;
|
|
|
|
/**
|
|
* 上报大鱼吃小鱼正式游玩。elapsedMs 为 0 时仅标记玩过作品。
|
|
*/
|
|
export function recordBigFishPlay(
|
|
sessionId: string,
|
|
payload: RecordBigFishPlayRequest,
|
|
options: BigFishRuntimeRequestOptions = {},
|
|
) {
|
|
return requestRuntimeJson<BigFishWorksResponse>({
|
|
url: buildRuntimeApiPath(
|
|
BIG_FISH_RUNTIME_API_BASE,
|
|
'sessions',
|
|
sessionId,
|
|
'play',
|
|
),
|
|
method: 'POST',
|
|
jsonBody: payload,
|
|
fallbackMessage: '记录大鱼吃小鱼游玩失败',
|
|
retry: BIG_FISH_RUNTIME_WRITE_RETRY,
|
|
requestOptions: options,
|
|
});
|
|
}
|
|
|
|
export function startBigFishRun(
|
|
sessionId: string,
|
|
options: BigFishRuntimeRequestOptions = {},
|
|
) {
|
|
return requestRuntimeJson<BigFishRunResponse>({
|
|
url: buildRuntimeApiPath(
|
|
BIG_FISH_RUNTIME_API_BASE,
|
|
'sessions',
|
|
sessionId,
|
|
'runs',
|
|
),
|
|
method: 'POST',
|
|
fallbackMessage: '启动大鱼吃小鱼玩法失败',
|
|
retry: BIG_FISH_RUNTIME_WRITE_RETRY,
|
|
requestOptions: options,
|
|
});
|
|
}
|
|
|
|
export function getBigFishRun(
|
|
runId: string,
|
|
options: BigFishRuntimeRequestOptions = {},
|
|
) {
|
|
return requestRuntimeJson<BigFishRunResponse>({
|
|
url: buildRuntimeApiPath(BIG_FISH_RUNTIME_API_BASE, 'runs', runId),
|
|
fallbackMessage: '读取大鱼吃小鱼玩法失败',
|
|
requestOptions: options,
|
|
});
|
|
}
|
|
|
|
export function submitBigFishInput(
|
|
runId: string,
|
|
payload: SubmitBigFishInputRequest,
|
|
options: BigFishRuntimeRequestOptions = {},
|
|
) {
|
|
return requestRuntimeJson<BigFishRunResponse>({
|
|
url: buildRuntimeApiPath(BIG_FISH_RUNTIME_API_BASE, 'runs', runId, 'input'),
|
|
method: 'POST',
|
|
jsonBody: payload,
|
|
fallbackMessage: '同步大鱼吃小鱼输入失败',
|
|
retry: BIG_FISH_RUNTIME_WRITE_RETRY,
|
|
requestOptions: options,
|
|
});
|
|
}
|