前端:游玩上报复用后台请求的鉴权降级策略
- gameDistributionClient.ts:删除与 BACKGROUND_AUTH_REQUEST_OPTIONS 逐字重复的 PLAY_REPORT_REQUEST_OPTIONS,改为直接复用该常量,避免两处 local/background 鉴权语义日后漂移
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
} from '../../packages/shared/src/contracts/gameDistribution';
|
||||
import {
|
||||
type ApiRequestOptions,
|
||||
BACKGROUND_AUTH_REQUEST_OPTIONS,
|
||||
requestJson as requestApiJson,
|
||||
} from './apiClient';
|
||||
import { getGamePlayClientId } from './gamePlayClientId';
|
||||
@@ -70,14 +71,8 @@ const PUBLIC_GAME_REQUEST_OPTIONS: ApiRequestOptions = {
|
||||
|
||||
/**
|
||||
* 游玩上报是后台尽力而为的请求:带上已登录 bearer(后端据此按 userId 去重),但即使遇到 401
|
||||
* 也不刷新会话、不改动全局登录态,避免一次计数把整站登录态带进刷新或登出流程。
|
||||
* 也不刷新会话、不改动全局登录态——直接复用后台请求已有的同一份鉴权降级策略。
|
||||
*/
|
||||
const PLAY_REPORT_REQUEST_OPTIONS: ApiRequestOptions = {
|
||||
authImpact: 'local',
|
||||
skipRefresh: true,
|
||||
notifyAuthStateChange: false,
|
||||
clearAuthOnUnauthorized: false,
|
||||
};
|
||||
|
||||
async function requestJson<T>(
|
||||
path: string,
|
||||
@@ -197,7 +192,7 @@ export function recordGamePlay(gameId: string) {
|
||||
body: JSON.stringify({ clientId: getGamePlayClientId() }),
|
||||
},
|
||||
'游玩上报失败',
|
||||
PLAY_REPORT_REQUEST_OPTIONS,
|
||||
BACKGROUND_AUTH_REQUEST_OPTIONS,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user