feat: enhance iframe communication and caching mechanisms
Some checks failed
lotteryfront CI / build (push) Has been cancelled

- Improved the entry lifecycle management to prevent duplicate token requests and ensure smooth transitions.
- Updated the `resolvePostMessageTargetOrigin` function to return null when no allowed origins are present, enhancing security.
- Cached runtime origins to optimize performance and reduce unnecessary API calls.
- Added a new error message for frozen lottery wallets in the player notifications.
This commit is contained in:
2026-06-16 17:08:34 +08:00
parent 9a42f47ac7
commit 9711909893
9 changed files with 59 additions and 19 deletions

View File

@@ -87,12 +87,15 @@ export function useTokenRefresh(): {
if (typeof window === "undefined") return;
// 向主站请求新 Token
const targetOrigin = resolvePostMessageTargetOrigin();
if (!targetOrigin) return;
window.parent.postMessage(
{
type: "LOTTERY_TOKEN_REFRESH_REQUEST",
timestamp: Date.now(),
},
resolvePostMessageTargetOrigin(),
targetOrigin,
);
}, []);