From 076271b5a9fdce5db7f8f4555ff7f55ed10d4d46 Mon Sep 17 00:00:00 2001 From: mac Date: Wed, 10 Jul 2024 15:37:01 +0800 Subject: [PATCH] commit --- .env | 4 ++-- src/pages/login/index.tsx | 31 +++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.env b/.env index 0e43446..bb9ab9e 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ SKIP_PREFLIGHT_CHECK=true -REACT_APP_BASE_URL=https://matontrading.com -REACT_APP_ORIGIN_URL=https://matontrading.com \ No newline at end of file +REACT_APP_BASE_URL=http://203.161.61.234:8082 +REACT_APP_ORIGIN_URL=http://162.254.37.253:8086 \ No newline at end of file diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index ad9dd9b..c073450 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -22,6 +22,7 @@ const LoginForm: FC = ({ const [form] = Form.useForm() const nameRef = useRef('') + const google_token = useRef('') const [codeUrl, setCodeUrl] = useState('') const codeId = useRef('') const [visible, setVisible] = useState(false) @@ -53,18 +54,23 @@ const LoginForm: FC = ({ const { username } = values; common.login({ ...values, id: codeId.current }).then((res: any) => { console.log(res); - if (res.code === 0 && !res.data.google) { - // 登录后返回的数据,包括权限 - const resData = { - userName: username, - token: res.data.token, - permission: res.data.c || [] + if (res.code === 0) { + if (res.data.google) { + nameRef.current = username + google_token.current = res.data.google_token + setVisible(true) + } else { + // 登录后返回的数据,包括权限 + const resData = { + userName: username, + token: res.data.token, + permission: res.data.c || [] + } + + setUserInfo(resData, setStoreData) + history.push('/') } - setUserInfo(resData, setStoreData) - history.push('/') - } else { - nameRef.current = username - setVisible(true) + } }) @@ -114,7 +120,8 @@ const LoginForm: FC = ({ const onVerifyFinish = async (values) => { const res: any = await api.verify_googleCode({ - code: Number(values.code) + code: Number(values.code), + google_token: google_token.current }) if (res.code === 0) { // 登录后返回的数据,包括权限