feat: 增强钱包 API 与玩家会话管理
- 新增钱包 API 函数:getWalletLogs(获取钱包日志)、postWalletTransferIn(充值)及 postWalletTransferOut(提现) - 更新钱包相关类型定义,提升类型安全性 - 改进玩家会话管理:若当前无玩家资料,则自动拉取玩家信息 - 增强入口网关对过期会话的错误处理能力 - 更新 UI 组件,以适配新的结构与功能
This commit is contained in:
@@ -4,7 +4,8 @@ import axios, {
|
||||
type AxiosResponse,
|
||||
} from "axios";
|
||||
|
||||
import { withPlayerAuthHeader } from "@/lib/lottery-auth";
|
||||
import { setPlayerBearerToken, withPlayerAuthHeader } from "@/lib/lottery-auth";
|
||||
import { clearPersistedPlayerBearerToken } from "@/lib/player-session";
|
||||
import { withLotteryLocaleHeaders } from "@/lib/lottery-locale";
|
||||
import {
|
||||
LotteryApiBizError,
|
||||
@@ -23,6 +24,25 @@ export const lotteryHttp = axios.create({
|
||||
headers: { Accept: "application/json" },
|
||||
});
|
||||
|
||||
/** 站内接口 401:清本地会话并回入口,与 {@link EntryGate} `session=expired` 衔接 */
|
||||
lotteryHttp.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error: unknown) => {
|
||||
if (
|
||||
isAxiosError(error) &&
|
||||
error.response?.status === 401 &&
|
||||
typeof window !== "undefined"
|
||||
) {
|
||||
clearPersistedPlayerBearerToken();
|
||||
setPlayerBearerToken(null);
|
||||
if (window.location.pathname !== "/") {
|
||||
window.location.replace("/?session=expired");
|
||||
}
|
||||
}
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 对 **payload**(通常是 `response.data`)校验信封并成功时返回 `data`;
|
||||
* `code !== 0` 抛 {@link LotteryApiBizError}。
|
||||
|
||||
Reference in New Issue
Block a user