diff --git a/.env.development b/.env.development index c2b3e9a..eeb149f 100644 --- a/.env.development +++ b/.env.development @@ -16,3 +16,7 @@ REACT_APP_GRAPH_API_LOTTERY = "https://api.thegraph.com/subgraphs/name/pancakesw REACT_APP_SNAPSHOT_BASE_URL = "https://testnet.snapshot.org" REACT_APP_SNAPSHOT_VOTING_API = "https://xtjyd0liqe.execute-api.ap-northeast-1.amazonaws.com/dev/api" + + + +REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090' diff --git a/.eslintrc b/.eslintrc index 4cbd176..bc519ce 100644 --- a/.eslintrc +++ b/.eslintrc @@ -33,7 +33,8 @@ "no-param-reassign": ["error", { "props": true, "ignorePropertyModificationsFor": ["state", "memo"] }], "react/require-default-props": 0, "no-nested-ternary": 0, - "max-classes-per-file": 0 + "max-classes-per-file": 0, + "react-hooks/exhaustive-deps":0 // End temporary rules } } diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index 7194980..8a04874 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -1,26 +1,49 @@ -import React from 'react' -import { Menu as UikitMenu } from '@pancakeswap/uikit' +import React, { useEffect, useState } from 'react' +import { Menu as UikitMenu, ConnectorNames } from '@pancakeswap/uikit' import { useWeb3React } from '@web3-react/core' import { languageList } from 'config/localization/languages' import { useTranslation } from 'contexts/Localization' import useTheme from 'hooks/useTheme' import useAuth from 'hooks/useAuth' +import { useDispatch } from 'react-redux' import { usePriceCakeBusd, useProfile } from 'state/hooks' +import { useUnactiveAccount, useSignLogin, useAccount } from 'state/userInfo/hooks' +import useWeb3Provider from 'hooks/useActiveWeb3React' +import { clearUserInfo } from 'state/actions' import config from './config' const Menu = (props) => { - const { account } = useWeb3React() + const account = useAccount() const { login, logout } = useAuth() + const [hasWalletLogin, setHasWalletLogin] = useState(false) const { isDark, toggleTheme } = useTheme() const cakePriceUsd = usePriceCakeBusd() + const { library } = useWeb3Provider() + const unActiveAccount = useUnactiveAccount() + const dispatch = useDispatch() const { profile } = useProfile() const { currentLanguage, setLanguage, t } = useTranslation() - + const sign = useSignLogin() + const handleLogin = async (connectorID: ConnectorNames) => { + await login(connectorID) + setHasWalletLogin(true) + } + const handleLogout = () => { + dispatch(clearUserInfo()) + logout() + } + // 钱包登录后 + useEffect(() => { + if (unActiveAccount && library.provider && hasWalletLogin) { + setHasWalletLogin(false) + sign() + } + }, [unActiveAccount, hasWalletLogin, library]) return ( { const { t } = useTranslation() const { login, logout } = useAuth() - const { onPresentConnectModal } = useWalletModal(login, logout) - + const [hasWalletLogin, setHasWalletLogin] = useState(false) + const { library } = useWeb3Provider() + const unActiveAccount = useUnactiveAccount() + const { toastInfo } = useToast() + const sign = useSignLogin() + const handleLogin = async (connectorID: ConnectorNames) => { + await login(connectorID) + setHasWalletLogin(true) + } + const { onPresentConnectModal } = useWalletModal(handleLogin, logout) + // 钱包登录后 + useEffect(() => { + if (unActiveAccount && library.provider && hasWalletLogin) { + setHasWalletLogin(false) + sign() + } + }, [unActiveAccount, hasWalletLogin, library]) return (