|
@@ -1,7 +1,7 @@
|
|
import { useEffect, useMemo, useState } from 'react'
|
|
import { useEffect, useMemo, useState } from 'react'
|
|
import './App.less'
|
|
import './App.less'
|
|
import LoginPop from './pages/loginPop'
|
|
import LoginPop from './pages/loginPop'
|
|
-import { getInitAppletApi, tokenExpireTimeCheckApi, weChatLoginApi } from './api'
|
|
|
|
|
|
+import { getInitAppletApi, setVisitLogPushApi, tokenExpireTimeCheckApi, weChatLoginApi } from './api'
|
|
import { useAjax } from './hooks/useAjax'
|
|
import { useAjax } from './hooks/useAjax'
|
|
import { removeGameId, removeToken, setGameId, setToken } from './utils/auth'
|
|
import { removeGameId, removeToken, setGameId, setToken } from './utils/auth'
|
|
import { Spin, App as AntdApp, Result } from 'antd'
|
|
import { Spin, App as AntdApp, Result } from 'antd'
|
|
@@ -24,6 +24,7 @@ function App() {
|
|
const searchParams = new URLSearchParams(new URL(url).search);
|
|
const searchParams = new URLSearchParams(new URL(url).search);
|
|
const gameId = searchParams.get('game_id')
|
|
const gameId = searchParams.get('game_id')
|
|
const isSw = searchParams.get('isSw')
|
|
const isSw = searchParams.get('isSw')
|
|
|
|
+ const vt = searchParams.get('vt')
|
|
const { state, dispatch, getDetails } = useConfig()
|
|
const { state, dispatch, getDetails } = useConfig()
|
|
const { typeSwitch, token } = state
|
|
const { typeSwitch, token } = state
|
|
// const [isInit, setIsInit] = useState<boolean>(false)
|
|
// const [isInit, setIsInit] = useState<boolean>(false)
|
|
@@ -33,13 +34,14 @@ function App() {
|
|
|
|
|
|
const getInitApplet = useAjax(() => getInitAppletApi())
|
|
const getInitApplet = useAjax(() => getInitAppletApi())
|
|
const weChatLogin = useAjax((params) => weChatLoginApi(params))
|
|
const weChatLogin = useAjax((params) => weChatLoginApi(params))
|
|
|
|
+ const setVisitLogPush = useAjax((params) => setVisitLogPushApi(params))
|
|
const tokenExpireTimeCheck = useAjax(() => tokenExpireTimeCheckApi())
|
|
const tokenExpireTimeCheck = useAjax(() => tokenExpireTimeCheckApi())
|
|
/**************************************/
|
|
/**************************************/
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
// sw
|
|
// sw
|
|
- if(isSw){
|
|
|
|
- localStorage.setItem("isSw",isSw)
|
|
|
|
|
|
+ if (isSw) {
|
|
|
|
+ localStorage.setItem("isSw", isSw)
|
|
}
|
|
}
|
|
function handleOrientationChange() {
|
|
function handleOrientationChange() {
|
|
let orientationType = 'VERTICAL'
|
|
let orientationType = 'VERTICAL'
|
|
@@ -77,6 +79,12 @@ function App() {
|
|
}
|
|
}
|
|
}, [gameId])
|
|
}, [gameId])
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (vt === '1' && gameId) {
|
|
|
|
+ setVisitLogPush.run({ url: window.location.href })
|
|
|
|
+ }
|
|
|
|
+ }, [vt, gameId])
|
|
|
|
+
|
|
// 监听token 获取用户信息
|
|
// 监听token 获取用户信息
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (token) {
|
|
if (token) {
|
|
@@ -117,13 +125,17 @@ function App() {
|
|
getInitApplet.run().then(res => {
|
|
getInitApplet.run().then(res => {
|
|
setIsLoding(false)
|
|
setIsLoding(false)
|
|
if (res?.data) {
|
|
if (res?.data) {
|
|
- let h5WeChatControl = res?.data?.h5GameConfigDTO?.h5WeChatControl || 'UN_CONTROL'
|
|
|
|
|
|
+ let h5WeChatControl = res?.data?.h5GameConfigMap?.h5WeChatControl || 'UN_CONTROL'
|
|
|
|
+ if (h5WeChatControl === 'ONLY_WE_CHAT' && !isWeChat()) {
|
|
|
|
+ window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=888"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
dispatch({ type: 'setIsPut', params: { isPut: (res.data.isPut && res.data.appId) || false } })
|
|
dispatch({ type: 'setIsPut', params: { isPut: (res.data.isPut && res.data.appId) || false } })
|
|
document.title = (res.data?.gameName || '游戏-登录')
|
|
document.title = (res.data?.gameName || '游戏-登录')
|
|
- dispatch({ type: 'setInitData', params: { initData: { ...res.data, ...res.data?.h5GameConfigDTO } } })
|
|
|
|
- if (res.data?.h5GameConfigDTO?.h5SignLogo) {
|
|
|
|
|
|
+ dispatch({ type: 'setInitData', params: { initData: { ...res.data, ...res.data?.h5GameConfigMap } } })
|
|
|
|
+ if (res.data?.h5GameConfigMap?.h5SignLogo) {
|
|
let iconLink: any = document.querySelector('link[rel="icon"]');
|
|
let iconLink: any = document.querySelector('link[rel="icon"]');
|
|
- iconLink.href = res.data?.h5GameConfigDTO?.h5SignLogo
|
|
|
|
|
|
+ iconLink.href = res.data?.h5GameConfigMap?.h5SignLogo
|
|
}
|
|
}
|
|
if (isWx() && ['ios', 'android'].includes(isOs()) && h5WeChatControl === 'UN_WE_CHAT') {
|
|
if (isWx() && ['ios', 'android'].includes(isOs()) && h5WeChatControl === 'UN_WE_CHAT') {
|
|
setIsPhoneWxShow(false)
|
|
setIsPhoneWxShow(false)
|