This commit is contained in:
myf 2022-05-05 20:54:53 +08:00
parent dd5c62b05e
commit 0aa34cfc85
4 changed files with 44 additions and 29 deletions

View File

@ -20,4 +20,4 @@ REACT_APP_SNAPSHOT_VOTING_API = "https://xtjyd0liqe.execute-api.ap-northeast-1.a
REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090' REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090'
# REACT_APP_REQUEST_URL = 'http://192.168.2.210:8080' # REACT_APP_REQUEST_URL = 'http://192.168.2.28:8080'

View File

@ -2,6 +2,7 @@ import React, { lazy, useEffect } from 'react'
import { Router, Redirect, Route, Switch } from 'react-router-dom' import { Router, Redirect, Route, Switch } from 'react-router-dom'
import { ResetCSS } from '@pancakeswap/uikit' import { ResetCSS } from '@pancakeswap/uikit'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { uccnDetail, indexInfo } from 'services/user'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
import useEagerConnect from 'hooks/useEagerConnect' import useEagerConnect from 'hooks/useEagerConnect'
import { usePollCoreFarmData, useFetchProfile, usePollBlockNumber } from 'state/hooks' import { usePollCoreFarmData, useFetchProfile, usePollBlockNumber } from 'state/hooks'

View File

@ -1,6 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react' import React, { useEffect, useState, useMemo } from 'react'
import { Menu as UikitMenu, ConnectorNames } from '@pancakeswap/uikit' import { Menu as UikitMenu, ConnectorNames } from '@pancakeswap/uikit'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { uccnDetail, indexInfo } from 'services/user'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { languageList } from 'config/localization/languages' import { languageList } from 'config/localization/languages'
import { useTranslation } from 'contexts/Localization' import { useTranslation } from 'contexts/Localization'
@ -10,10 +11,11 @@ import { usePriceHccUsdt, useProfile } from 'state/hooks'
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo } 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 } from 'state/actions' import { clearUserInfo } from 'state/actions'
import { uccnDetail } from 'services/user'
import config from './config' import config from './config'
const list = []
const Menu = (props) => { const Menu = (props) => {
console.log(props)
const account = useAccount() const account = useAccount()
const { login, logout } = useAuth() const { login, logout } = useAuth()
const [hasWalletLogin, setHasWalletLogin] = useState(false) const [hasWalletLogin, setHasWalletLogin] = useState(false)
@ -39,6 +41,20 @@ const Menu = (props) => {
dispatch(clearUserInfo()) dispatch(clearUserInfo())
logout() logout()
} }
const [linkList, setLinkList] = useState([])
const getDetails = async () => {
const result = await indexInfo()
const { data } = result.data
data.externalLinkList.forEach((item) => {
const links = []
Object.keys(item.linkMap).forEach((key) => {
links.push({ name: key, link: item.linkMap[key], icon: item.iconResource.url })
})
list.push({ icon: item.iconResource.url, list: links })
})
setLinkList(list)
}
// 钱包登录后 // 钱包登录后
useEffect(() => { useEffect(() => {
if (unActiveAccount && library.provider && hasWalletLogin) { if (unActiveAccount && library.provider && hasWalletLogin) {
@ -47,20 +63,8 @@ const Menu = (props) => {
} }
}, [unActiveAccount, hasWalletLogin, library]) }, [unActiveAccount, hasWalletLogin, library])
const [detail, setDetail] = useState({
outSideChainNumb: '',
outsideChainVos: [],
telegramNumb: '',
tradingVolume: '',
userNumb: '',
})
const getDetail = async () => {
const result = await uccnDetail()
const { data } = result.data
setDetail(data)
}
useEffect(() => { useEffect(() => {
getDetail() getDetails()
}, []) }, [])
return ( return (
@ -76,7 +80,7 @@ const Menu = (props) => {
setLang={setLanguage} setLang={setLanguage}
cakePriceUsd={hccPriceUsdt.toNumber()} cakePriceUsd={hccPriceUsdt.toNumber()}
links={config(t)} links={config(t)}
outLink={detail?.outsideChainVos} outLink={linkList}
{...props} {...props}
/> />
) )

View File

@ -134,21 +134,32 @@ const FristCom: React.FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
const dispatch = useDispatch() const dispatch = useDispatch()
const [detail, setDetail] = useState({ const [detail, setDetail] = useState({
outSideChainNumb: '', externalLinkList: [],
outsideChainVos: [], userCount: '',
telegramNumb: '', volume: '',
tradingVolume: '',
userNumb: '',
}) })
const [linkList, setLinkList] = useState([])
const getDetail = async () => { const getDetail = async () => {
const data = await uccnDetail() const data = await indexInfo()
const list = []
data.externalLinkList.forEach((item) => {
const links = []
Object.keys(item.linkMap).forEach((key) => {
links.push({ name: key, link: item.linkMap[key], icon: item.iconResource.url })
})
list.push({ icon: item.iconResource.url, list: links })
})
setLinkList(list)
setDetail(data) setDetail(data)
} }
useEffect(() => { useEffect(() => {
getDetail() getDetail()
}, []) }, [])
const openLink = (link) => { const openLink = (link) => {
window.open(link) console.log('link:', link)
// window.open(link)
window.location.href = link
} }
return ( return (
<> <>
@ -169,16 +180,15 @@ const FristCom: React.FC = () => {
</RadiusBtn> </RadiusBtn>
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */} {/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
<Flex> <Flex>
{detail?.outsideChainVos?.map((item) => { {linkList?.map((item) => {
return ( return (
<BtnImage <BtnImage
key={item.id}
style={{ borderRadius: '50%' }} style={{ borderRadius: '50%' }}
src={item.cover} src={item.icon}
alt={item.name} alt={item.name}
width={34} width={34}
height={34} height={34}
onClick={() => openLink(item.link)} onClick={() => openLink(item.list[0].link)}
/> />
) )
})} })}
@ -189,8 +199,8 @@ const FristCom: React.FC = () => {
</InfoDiv> </InfoDiv>
</FlexDiv> </FlexDiv>
<ScoreDiv> <ScoreDiv>
<FlexItemCom name={t('Number of holders')} valueNum={detail?.userNumb} /> <FlexItemCom name={t('Number of holders')} valueNum={detail?.userCount} />
<FlexItemCom name={t('Your volume')} valueNum={detail?.tradingVolume} /> <FlexItemCom name={t('Your volume')} valueNum={detail?.volume} />
<FlexItemCom name={t('market value')} valueNum={0} /> <FlexItemCom name={t('market value')} valueNum={0} />
{/* {burned.map((item) => { {/* {burned.map((item) => {
return <FlexItemCom key={item.id} name={item.name} value={item.value} /> return <FlexItemCom key={item.id} name={item.name} value={item.value} />