|
@@ -22,21 +22,30 @@ const SportsClient: FC<Props> = (props) => {
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ console.log("onLoad=====>0000");
|
|
|
// @ts-ignore
|
|
|
if (window.BTRenderer) {
|
|
|
+ console.log("onLoad=====>1111");
|
|
|
onLoad();
|
|
|
}
|
|
|
|
|
|
// 离开体育页的时候需要kill掉
|
|
|
return () => {
|
|
|
+ console.log("onLoad=====>killkillkillkillkill");
|
|
|
+ if(btRef.current){
|
|
|
// @ts-ignore
|
|
|
btRef.current?.kill();
|
|
|
+ btRef.current = null;
|
|
|
+ }
|
|
|
+
|
|
|
};
|
|
|
}, []);
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ console.log("onLoad=====>22222");
|
|
|
// 如果token更新了才调用update
|
|
|
if( currentToken !== token){
|
|
|
+ console.log("onLoad=====>333333");
|
|
|
updateToken(token);
|
|
|
}
|
|
|
}, [token]);
|
|
@@ -60,59 +69,66 @@ const SportsClient: FC<Props> = (props) => {
|
|
|
};
|
|
|
|
|
|
const updateToken = (newToken: string) => {
|
|
|
+ console.log("onLoad=====>44444-0000000");
|
|
|
// @ts-ignore
|
|
|
if(currentToken!== newToken){
|
|
|
+ console.log("onLoad=====>44444");
|
|
|
setCurrentToken(newToken);
|
|
|
- }
|
|
|
- // @ts-ignore
|
|
|
- if (window.BTRenderer) {
|
|
|
- onLoad();
|
|
|
+ // 使用 updateOptions 更新当前的 BTRenderer 参数,而不是重新初始化
|
|
|
+ if (btRef.current) {
|
|
|
+ console.log("onLoad=====>55555");
|
|
|
+ // 更新 token 和其他配置
|
|
|
+ // @ts-ignore
|
|
|
+ btRef.current.updateOptions({
|
|
|
+ token: newToken, // 更新 token
|
|
|
+ url: '/', // 更新 URL 或其他参数
|
|
|
+ betSlipOffsetBottom: 80,
|
|
|
+ betSlipZIndex: 1000,
|
|
|
+ stickyTop: 0,
|
|
|
+ betSlipOffsetTop: 50,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const onLoad = () => {
|
|
|
- // @ts-ignore
|
|
|
- const bt = new BTRenderer();
|
|
|
- btRef.current = bt;
|
|
|
- // bt.updateOptions({url:'/'})
|
|
|
- bt.initialize({
|
|
|
- brand_id: brand_id,
|
|
|
- token: token,//使用最新的token
|
|
|
- onTokenExpired: getGameDetailApi, //过期自动更新token
|
|
|
- onSessionRefresh: () => {
|
|
|
-
|
|
|
- // 销毁之前的实例并等待刷新完成
|
|
|
- if(btRef.current){
|
|
|
- // @ts-ignore
|
|
|
- btRef.current?.kill();
|
|
|
- }
|
|
|
-
|
|
|
- router.refresh()
|
|
|
- },
|
|
|
- themeName: "default",
|
|
|
- lang: "pt-br",
|
|
|
- target: document.getElementById("betby"),
|
|
|
- betSlipOffsetBottom: 80,
|
|
|
- // betSlipOffsetRight: 750,
|
|
|
+ // @ts-ignore
|
|
|
+ const bt = new BTRenderer();
|
|
|
+ btRef.current = bt;
|
|
|
+ console.log("onLoad=====>666666",token);
|
|
|
+ bt.initialize({
|
|
|
+ brand_id: brand_id,
|
|
|
+ token: token,//使用最新的token
|
|
|
+ onTokenExpired: getGameDetailApi, //过期自动更新token
|
|
|
+ onSessionRefresh: () => {
|
|
|
+ // 销毁之前的实例并等待刷新完成
|
|
|
+ if(btRef.current){
|
|
|
+ // @ts-ignore
|
|
|
+ btRef.current?.kill();
|
|
|
+ }
|
|
|
+
|
|
|
+ router.refresh()
|
|
|
+ },
|
|
|
+ themeName: "default",
|
|
|
+ lang: "pt-br",
|
|
|
+ target: document.getElementById("betby"),
|
|
|
+ betSlipOffsetBottom: 80,
|
|
|
+ // betSlipOffsetRight: 750,
|
|
|
|
|
|
- betSlipZIndex: 1000,
|
|
|
- stickyTop: 0,
|
|
|
- betSlipOffsetTop: 50,
|
|
|
- onRecharge: function () {
|
|
|
- router.push("/deposit");
|
|
|
- },
|
|
|
- onRouteChange: function () {
|
|
|
- },
|
|
|
- onLogin: function () {},
|
|
|
- onRegister: function () {},
|
|
|
- onBetSlipStateChange: function () {},
|
|
|
- });
|
|
|
+ betSlipZIndex: 1000,
|
|
|
+ stickyTop: 0,
|
|
|
+ betSlipOffsetTop: 50,
|
|
|
+ onRecharge: function () {
|
|
|
+ router.push("/deposit");
|
|
|
+ },
|
|
|
+ onRouteChange: function () {
|
|
|
+ },
|
|
|
+ onLogin: function () {},
|
|
|
+ onRegister: function () {},
|
|
|
+ onBetSlipStateChange: function () {},
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
<div id="betby" className={"h-[100%]"}></div>
|