|
@@ -1,9 +1,8 @@
|
|
|
import { LockOutlined, UserOutlined } from '@ant-design/icons'
|
|
import { LockOutlined, UserOutlined } from '@ant-design/icons'
|
|
|
import { Alert, notification, Tabs } from 'antd'
|
|
import { Alert, notification, Tabs } from 'antd'
|
|
|
-import React, { useState } from 'react'
|
|
|
|
|
|
|
+import React, { useState, useTransition } from 'react'
|
|
|
import ProForm, { ProFormCheckbox, ProFormText } from '@ant-design/pro-form'
|
|
import ProForm, { ProFormCheckbox, ProFormText } from '@ant-design/pro-form'
|
|
|
-import { useIntl, history, FormattedMessage, useModel } from '@umijs/max'
|
|
|
|
|
-
|
|
|
|
|
|
|
+import { useIntl, history, FormattedMessage, useModel, createSearchParams } from '@umijs/max'
|
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
|
import { apiLogin } from '@/services/login'
|
|
import { apiLogin } from '@/services/login'
|
|
|
import { setAuthCache } from '@/utils/auth'
|
|
import { setAuthCache } from '@/utils/auth'
|
|
@@ -11,7 +10,7 @@ import { TOKEN_KEY } from '@/utils/cache/cacheEnum'
|
|
|
import { DEFAULT_CACHE_TIME } from '@/settings/encryptionSetting'
|
|
import { DEFAULT_CACHE_TIME } from '@/settings/encryptionSetting'
|
|
|
import consts from '@/consts'
|
|
import consts from '@/consts'
|
|
|
import { isUnDef } from '@/utils/is'
|
|
import { isUnDef } from '@/utils/is'
|
|
|
-
|
|
|
|
|
|
|
+import 'antd/lib/notification/style'
|
|
|
const LoginMessage = ({ content }) => (
|
|
const LoginMessage = ({ content }) => (
|
|
|
<Alert
|
|
<Alert
|
|
|
style={{
|
|
style={{
|
|
@@ -29,8 +28,8 @@ const Login = () => {
|
|
|
status: '',
|
|
status: '',
|
|
|
type: 'account'
|
|
type: 'account'
|
|
|
})
|
|
})
|
|
|
|
|
+ const [, startTransition] = useTransition()
|
|
|
const { initialState, setInitialState } = useModel('@@initialState')
|
|
const { initialState, setInitialState } = useModel('@@initialState')
|
|
|
-
|
|
|
|
|
const intl = useIntl()
|
|
const intl = useIntl()
|
|
|
|
|
|
|
|
const fetchUserInfo = async () => {
|
|
const fetchUserInfo = async () => {
|
|
@@ -45,17 +44,18 @@ const Login = () => {
|
|
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
|
|
const goto = username => {
|
|
const goto = username => {
|
|
|
if (!history) return
|
|
if (!history) return
|
|
|
- const searchParams = new URLSearchParams(history.location.search)
|
|
|
|
|
|
|
+ const searchParams = createSearchParams(window.location.search)
|
|
|
const redirect = searchParams.get('redirect')
|
|
const redirect = searchParams.get('redirect')
|
|
|
- console.log(redirect)
|
|
|
|
|
- // 清除所有notification
|
|
|
|
|
- notification.destroy()
|
|
|
|
|
- notification.success({
|
|
|
|
|
- message: intl.formatMessage({ id: 'pages.login.success.title' }),
|
|
|
|
|
- description: redirect && `${intl.formatMessage({ id: 'pages.login.success.desc' })}: ${username}`,
|
|
|
|
|
- duration: 3
|
|
|
|
|
|
|
+ startTransition(() => {
|
|
|
|
|
+ // 清除所有notification
|
|
|
|
|
+ notification.destroy()
|
|
|
|
|
+ notification.success({
|
|
|
|
|
+ message: intl.formatMessage({ id: 'pages.login.success.title' }),
|
|
|
|
|
+ description: redirect && `${intl.formatMessage({ id: 'pages.login.success.desc' })}: ${username}`,
|
|
|
|
|
+ duration: 3
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
- return history.replace(redirect || '/')
|
|
|
|
|
|
|
+ history.replace(redirect || '/')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleSubmit = async values => {
|
|
const handleSubmit = async values => {
|