feat(hall): 优化桌面端投注表格布局与国际化文本支持
Some checks failed
lotteryfront CI / build (push) Has been cancelled

This commit is contained in:
2026-07-13 10:23:44 +08:00
parent 99d49f457f
commit c74bd5f701
6 changed files with 136 additions and 91 deletions

View File

@@ -1,4 +1,5 @@
import { useCallback, useEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
import { parseJwtExp } from "@/lib/jwt-payload";
import { usePlayerSessionStore } from "@/stores/player-session-store";
@@ -39,6 +40,7 @@ export function useTokenRefresh(): {
const setBearerToken = usePlayerSessionStore((state) => state.setBearerToken);
const setServerError = useErrorStore((state) => state.setServerError);
const clearServerError = useErrorStore((state) => state.clearServerError);
const { t } = useTranslation("player");
const refreshTimerRef = useRef<NodeJS.Timeout | null>(null);
const retryCountRef = useRef(0);
@@ -89,7 +91,7 @@ export function useTokenRefresh(): {
*/
const refreshToken = useCallback(async (): Promise<void> => {
if (retryCountRef.current >= MAX_RETRY) {
setServerError(true, "Token 刷新失败,请返回主站重新进入");
setServerError(true, t("token.refreshFailed"));
return;
}
@@ -102,10 +104,10 @@ export function useTokenRefresh(): {
if (pendingRefreshRef.current !== attemptId) return;
retryCountRef.current += 1;
if (retryCountRef.current >= MAX_RETRY) {
setServerError(true, "Token 刷新失败,请返回主站重新进入");
setServerError(true, t("token.refreshFailed"));
}
}, REFRESH_RESPONSE_TIMEOUT_MS);
}, [clearServerError, requestParentRefresh, setServerError]);
}, [clearServerError, requestParentRefresh, setServerError, t]);
/**
* 监听主站 postMessage 发送的新 Token