This commit is contained in:
parent
153760dc2c
commit
dd5c62b05e
|
|
@ -8,7 +8,7 @@ import { usePollCoreFarmData, useFetchProfile, usePollBlockNumber } from 'state/
|
||||||
import { DatePickerPortal } from 'components/DatePicker'
|
import { DatePickerPortal } from 'components/DatePicker'
|
||||||
import { initAxios } from 'utils/request'
|
import { initAxios } from 'utils/request'
|
||||||
import useToast from 'hooks/useToast'
|
import useToast from 'hooks/useToast'
|
||||||
import { fetchUserInfo, clearUserInfo, fetchOutInfo } from 'state/actions'
|
import { fetchUserInfo, clearUserInfo } from 'state/actions'
|
||||||
import { useAccount } from 'state/userInfo/hooks'
|
import { useAccount } from 'state/userInfo/hooks'
|
||||||
import GlobalStyle from './style/Global'
|
import GlobalStyle from './style/Global'
|
||||||
import Menu from './components/Menu'
|
import Menu from './components/Menu'
|
||||||
|
|
@ -70,7 +70,6 @@ const App: React.FC = () => {
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// dispatch(fetchOutInfo())
|
|
||||||
initAxios(() => {
|
initAxios(() => {
|
||||||
dispatch(clearUserInfo)
|
dispatch(clearUserInfo)
|
||||||
}, toast)
|
}, toast)
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,13 @@ import { useTranslation } from 'contexts/Localization'
|
||||||
import useTheme from 'hooks/useTheme'
|
import useTheme from 'hooks/useTheme'
|
||||||
import useAuth from 'hooks/useAuth'
|
import useAuth from 'hooks/useAuth'
|
||||||
import { usePriceHccUsdt, useProfile } from 'state/hooks'
|
import { usePriceHccUsdt, useProfile } from 'state/hooks'
|
||||||
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo, useOutLink } from 'state/userInfo/hooks'
|
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo } from 'state/userInfo/hooks'
|
||||||
import useWeb3Provider from 'hooks/useActiveWeb3React'
|
import useWeb3Provider from 'hooks/useActiveWeb3React'
|
||||||
import { clearUserInfo, fetchOutInfo } from 'state/actions'
|
import { clearUserInfo } from 'state/actions'
|
||||||
import { uccnDetail } from 'services/user'
|
import { uccnDetail } from 'services/user'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
|
|
||||||
const Menu = (props) => {
|
const Menu = (props) => {
|
||||||
// const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] })
|
|
||||||
// const getDetail = async () => {
|
|
||||||
// const data = await uccnDetail()
|
|
||||||
// setDetail(data)
|
|
||||||
// }
|
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
const { login, logout } = useAuth()
|
const { login, logout } = useAuth()
|
||||||
const [hasWalletLogin, setHasWalletLogin] = useState(false)
|
const [hasWalletLogin, setHasWalletLogin] = useState(false)
|
||||||
|
|
@ -51,17 +46,22 @@ const Menu = (props) => {
|
||||||
sign()
|
sign()
|
||||||
}
|
}
|
||||||
}, [unActiveAccount, hasWalletLogin, library])
|
}, [unActiveAccount, hasWalletLogin, library])
|
||||||
// dispatch(fetchOutInfo())
|
|
||||||
// const detail = useOutLink()
|
const [detail, setDetail] = useState({
|
||||||
// console.log('detail123456:', detail.outsideChainVos)
|
outSideChainNumb: '',
|
||||||
|
outsideChainVos: [],
|
||||||
|
telegramNumb: '',
|
||||||
|
tradingVolume: '',
|
||||||
|
userNumb: '',
|
||||||
|
})
|
||||||
|
const getDetail = async () => {
|
||||||
|
const result = await uccnDetail()
|
||||||
|
const { data } = result.data
|
||||||
|
setDetail(data)
|
||||||
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// dispatch(fetchOutInfo())
|
getDetail()
|
||||||
// getDetail()
|
|
||||||
// const detail = useOutLink()
|
|
||||||
dispatch(fetchOutInfo())
|
|
||||||
}, [])
|
}, [])
|
||||||
const detail = useOutLink()
|
|
||||||
console.log(config(t))
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UikitMenu
|
<UikitMenu
|
||||||
|
|
@ -76,7 +76,7 @@ const Menu = (props) => {
|
||||||
setLang={setLanguage}
|
setLang={setLanguage}
|
||||||
cakePriceUsd={hccPriceUsdt.toNumber()}
|
cakePriceUsd={hccPriceUsdt.toNumber()}
|
||||||
links={config(t)}
|
links={config(t)}
|
||||||
outLink={detail.outsideChainVos}
|
outLink={detail?.outsideChainVos}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,11 @@ export const uccnDetail = () => {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export const indexInfo = () => {
|
||||||
|
return request.request({
|
||||||
|
url: '/high_city/app/api/index/info',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default queryUserInfo
|
export default queryUserInfo
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export {
|
||||||
updateUserPendingReward,
|
updateUserPendingReward,
|
||||||
updateUserStakedBalance,
|
updateUserStakedBalance,
|
||||||
} from './pools'
|
} from './pools'
|
||||||
export { setUserInfo, clearUserInfo, fetchUserInfo, fetchOutInfo } from './userInfo'
|
export { setUserInfo, clearUserInfo, fetchUserInfo } from './userInfo'
|
||||||
export { fetchReferralInfoAsync } from './referral'
|
export { fetchReferralInfoAsync } from './referral'
|
||||||
export { fetchBoardsPublicDataAsync, fetchBoardUserDataAsync } from './boards'
|
export { fetchBoardsPublicDataAsync, fetchBoardUserDataAsync } from './boards'
|
||||||
export { profileFetchStart, profileFetchSucceeded, profileFetchFailed } from './profile'
|
export { profileFetchStart, profileFetchSucceeded, profileFetchFailed } from './profile'
|
||||||
|
|
|
||||||
|
|
@ -484,6 +484,10 @@ export interface UserInfoState {
|
||||||
outLink?: OutLink
|
outLink?: OutLink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OutLinkState {
|
||||||
|
home: OutLink
|
||||||
|
}
|
||||||
|
|
||||||
export interface ReferralState {
|
export interface ReferralState {
|
||||||
commanderConfigInfo: ReferralConfigInfo
|
commanderConfigInfo: ReferralConfigInfo
|
||||||
normalConfigInfo: ReferralConfigInfo
|
normalConfigInfo: ReferralConfigInfo
|
||||||
|
|
@ -520,4 +524,5 @@ export interface State {
|
||||||
referral: ReferralState
|
referral: ReferralState
|
||||||
boards: BoardsState
|
boards: BoardsState
|
||||||
lottery: LotteryState
|
lottery: LotteryState
|
||||||
|
home?: OutLink
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ export const useToken = () => {
|
||||||
export const useUserInfo = () => {
|
export const useUserInfo = () => {
|
||||||
return useSelector((state: State) => state.userInfo.userInfo)
|
return useSelector((state: State) => state.userInfo.userInfo)
|
||||||
}
|
}
|
||||||
export const useOutLink = () => {
|
|
||||||
return useSelector((state: State) => state.userInfo.outLink)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 签名登录
|
// 签名登录
|
||||||
export const useSignLogin = () => {
|
export const useSignLogin = () => {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
|
||||||
import { queryUserInfo, uccnDetail } from 'services/user'
|
import { queryUserInfo } from 'services/user'
|
||||||
import { CACHE_TOKEN, CACHE_ACCOUNT, CACHE_USERINFO } from 'config/constants/cacheKey'
|
import { CACHE_TOKEN, CACHE_ACCOUNT, CACHE_USERINFO } from 'config/constants/cacheKey'
|
||||||
import { UserInfo, OutLink } from 'types/user'
|
import { UserInfo } from 'types/user'
|
||||||
import { UserInfoState } from '../types'
|
import { UserInfoState } from '../types'
|
||||||
|
|
||||||
const initialState: UserInfoState = {
|
const initialState: UserInfoState = {
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
outLink: {},
|
|
||||||
token: localStorage.getItem(CACHE_TOKEN),
|
token: localStorage.getItem(CACHE_TOKEN),
|
||||||
account: localStorage.getItem(CACHE_ACCOUNT),
|
account: localStorage.getItem(CACHE_ACCOUNT),
|
||||||
}
|
}
|
||||||
|
|
@ -16,11 +15,6 @@ export const fetchUserInfo = createAsyncThunk<UserInfo, null>('userInfo/fetchUse
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
export const fetchOutInfo = createAsyncThunk<OutLink, null>('uccn/detail', async () => {
|
|
||||||
const result = await uccnDetail()
|
|
||||||
return result
|
|
||||||
})
|
|
||||||
|
|
||||||
export const userInfoSlice = createSlice({
|
export const userInfoSlice = createSlice({
|
||||||
name: 'userInfo',
|
name: 'userInfo',
|
||||||
initialState,
|
initialState,
|
||||||
|
|
@ -28,7 +22,6 @@ export const userInfoSlice = createSlice({
|
||||||
setUserInfo: (state, action) => {
|
setUserInfo: (state, action) => {
|
||||||
const info = action.payload
|
const info = action.payload
|
||||||
state.userInfo = info
|
state.userInfo = info
|
||||||
state.outLink = info.outLink
|
|
||||||
state.account = info.address
|
state.account = info.address
|
||||||
info.token && (state.token = info.token)
|
info.token && (state.token = info.token)
|
||||||
localStorage.setItem(CACHE_TOKEN, state.token)
|
localStorage.setItem(CACHE_TOKEN, state.token)
|
||||||
|
|
@ -43,22 +36,15 @@ export const userInfoSlice = createSlice({
|
||||||
localStorage.removeItem(CACHE_USERINFO)
|
localStorage.removeItem(CACHE_USERINFO)
|
||||||
localStorage.removeItem(CACHE_ACCOUNT)
|
localStorage.removeItem(CACHE_ACCOUNT)
|
||||||
},
|
},
|
||||||
setOutLinkInfo: (state, action) => {
|
|
||||||
state.outLink = action.payload.outLink
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(fetchUserInfo.fulfilled, (state, action) => {
|
builder.addCase(fetchUserInfo.fulfilled, (state, action) => {
|
||||||
state.userInfo = action.payload
|
state.userInfo = action.payload
|
||||||
localStorage.setItem(CACHE_USERINFO, JSON.stringify(state.userInfo))
|
localStorage.setItem(CACHE_USERINFO, JSON.stringify(state.userInfo))
|
||||||
})
|
})
|
||||||
builder.addCase(fetchOutInfo.fulfilled, (state, action) => {
|
|
||||||
localStorage.setItem('cs', 'cs')
|
|
||||||
state.outLink = action.payload
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
export const { setUserInfo, clearUserInfo, setOutLinkInfo } = userInfoSlice.actions
|
export const { setUserInfo, clearUserInfo } = userInfoSlice.actions
|
||||||
export default userInfoSlice.reducer
|
export default userInfoSlice.reducer
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,24 @@ export interface UserInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OutLink {
|
export interface OutLink {
|
||||||
outSideChainNumb?: string
|
externalLinkList?: OutLinkList[]
|
||||||
outsideChainVos?: OUtLinkList[]
|
userCount?: string
|
||||||
telegramNumb?: string
|
volume?: string
|
||||||
tradingVolume?: string
|
|
||||||
userNumb?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OUtLinkList {
|
export interface OutLinkList {
|
||||||
content?: string
|
|
||||||
cover?: string
|
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
englishName?: string
|
iconResource?: IconResource
|
||||||
id?: string
|
id?: string
|
||||||
link?: string
|
englishName?: string
|
||||||
|
linkMap?: any
|
||||||
name?: string
|
name?: string
|
||||||
orderNumber?: string
|
orderNum?: string
|
||||||
|
remark?: string
|
||||||
updatedAt?: string
|
updatedAt?: string
|
||||||
}
|
}
|
||||||
|
export interface IconResource {
|
||||||
|
path: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { useOutLink } from 'state/userInfo/hooks'
|
import { uccnDetail, indexInfo } from 'services/user'
|
||||||
import { fetchOutInfo } from 'state/actions'
|
|
||||||
import { uccnDetail } from 'services/user'
|
|
||||||
import { Flex, Heading, Text, Box, Button, Image, Link } from '@pancakeswap/uikit'
|
import { Flex, Heading, Text, Box, Button, Image, Link } from '@pancakeswap/uikit'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
import { OutLink } from 'types/user'
|
import { OutLink } from 'types/user'
|
||||||
|
|
@ -135,19 +133,20 @@ const InfoDiv = styled.div``
|
||||||
const FristCom: React.FC = () => {
|
const FristCom: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
// const [burned, BurnedState] = useState([
|
const [detail, setDetail] = useState({
|
||||||
// { id: 'userNumb', name: '持有人数量', value: '0' },
|
outSideChainNumb: '',
|
||||||
// { id: 'tradingVolume', name: '交易量', value: '0' },
|
outsideChainVos: [],
|
||||||
// { id: 3, name: '市值', value: '62.55%' },
|
telegramNumb: '',
|
||||||
// ])
|
tradingVolume: '',
|
||||||
// const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] })
|
userNumb: '',
|
||||||
// const getDetail = async () => {
|
})
|
||||||
// const data = await uccnDetail()
|
const getDetail = async () => {
|
||||||
// setDetail(data)
|
const data = await uccnDetail()
|
||||||
// }
|
setDetail(data)
|
||||||
dispatch(fetchOutInfo())
|
}
|
||||||
const detail = useOutLink()
|
useEffect(() => {
|
||||||
console.log('detail123:', detail)
|
getDetail()
|
||||||
|
}, [])
|
||||||
const openLink = (link) => {
|
const openLink = (link) => {
|
||||||
window.open(link)
|
window.open(link)
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +169,7 @@ const FristCom: React.FC = () => {
|
||||||
</RadiusBtn>
|
</RadiusBtn>
|
||||||
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
|
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
|
||||||
<Flex>
|
<Flex>
|
||||||
{detail.outsideChainVos?.map((item) => {
|
{detail?.outsideChainVos?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<BtnImage
|
<BtnImage
|
||||||
key={item.id}
|
key={item.id}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue