前端:统一游玩上报的返回类型
- gameDistributionClient.ts:recordGamePlay 标注 Promise<{ recorded?: boolean }>,空 id 分支也返回同形状对象,消除 Promise<void> 与对象 Promise 的联合类型
This commit is contained in:
@@ -181,9 +181,11 @@ export async function getGame(gameId: string) {
|
||||
/**
|
||||
* 上报一次「开始游戏」。调用方按 fire-and-forget 处理:失败只静默忽略,绝不阻断进入游戏。
|
||||
*/
|
||||
export function recordGamePlay(gameId: string) {
|
||||
export function recordGamePlay(
|
||||
gameId: string,
|
||||
): Promise<{ recorded?: boolean }> {
|
||||
const normalizedId = gameId.trim();
|
||||
if (!normalizedId) return Promise.resolve();
|
||||
if (!normalizedId) return Promise.resolve({ recorded: false });
|
||||
return requestJson<{ recorded?: boolean }>(
|
||||
`/games/${encodeURIComponent(normalizedId)}/plays`,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user