Add login and logout notification

This commit is contained in:
2023-10-30 00:26:19 +08:00
parent 5d71433d63
commit fcd4fd532c
10 changed files with 134 additions and 25 deletions

View File

@@ -7,7 +7,9 @@ import {
} from '@/constants/common.constants'
import '@/assets/css/pages/login.scss'
import { setToken } from '@/utils/common'
import { login } from '@/utils/auth'
import { getUserInfo, login } from '@/utils/auth'
import { notification } from 'antd'
import moment from 'moment'
const Login: React.FC = () => {
const [messageApi, contextHolder] = message.useMessage()
@@ -31,6 +33,27 @@ const Login: React.FC = () => {
} else {
navigate('/')
}
void getUserInfo().then((user) => {
notification.success({
message: '欢迎回来',
description: (
<>
<span>
<strong>{user.username}</strong>
</span>
<br />
<span>
{moment(user.lastLoginTime).format(
'yyyy-MM-DD HH:mm:ssZ'
)}
{user.lastLoginIp}
</span>
</>
),
placement: 'topRight'
})
})
}, 1500)
break
case SYSTEM_USERNAME_NOT_FOUND: