|
@@ -0,0 +1,61 @@
|
|
|
+import { userStore } from '@/store/mobx'
|
|
|
+import { apiExternalAuthLogin } from '@/utils/common/api'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import history from '@/utils/history'
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
+import cycling from '../../assets/img/svg_cycling.png'
|
|
|
+import wrong from '../../assets/img/svg_wrong.png'
|
|
|
+import './index.less'
|
|
|
+
|
|
|
+enum authStatus {
|
|
|
+ success = 0,
|
|
|
+ fail = 1,
|
|
|
+ wait = 2
|
|
|
+}
|
|
|
+const PreAuth = () => {
|
|
|
+ const [ status, setStatus ] = useState(authStatus.wait)
|
|
|
+ useEffect(() => {
|
|
|
+ const token = window.location.search.split('=')[1]
|
|
|
+ async function authLogin() {
|
|
|
+ const { code = -1, data } = await apiExternalAuthLogin(token)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ setStatus(authStatus.success)
|
|
|
+ userStore.updateUserInfo(data)
|
|
|
+ userStore.getProjectInfo()
|
|
|
+ setTimeout(() => {
|
|
|
+ history.replace('/console/dashboard')
|
|
|
+ }, 250)
|
|
|
+ } else {
|
|
|
+ setStatus(authStatus.fail)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ authLogin()
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className='pre-auth-container'>
|
|
|
+ <img src={status === authStatus.fail ? wrong : cycling} alt="" />
|
|
|
+ {
|
|
|
+ status === authStatus.wait ? <div className='pre-auth-progress'>
|
|
|
+ <div className='pre-auth-loading' />
|
|
|
+ </div> : null
|
|
|
+ }
|
|
|
+
|
|
|
+ <div className='pre-auth-status'>
|
|
|
+ {
|
|
|
+ status === authStatus.wait ? <span>
|
|
|
+ 正在进入...
|
|
|
+ </span> : null
|
|
|
+ }
|
|
|
+ {
|
|
|
+ status === authStatus.fail ? <><span>请返回计量支付并</span>
|
|
|
+ <span className='link' onClick={() => window.location.href= 'http://127.0.0.1:7002/dashboard'}>重新进入</span></> : null
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default PreAuth
|