401.js
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
*name: 401页
*path: /401
*creator: zyj
*create-date: 20200722
*modifier:
*modify-date:
* */
import React, { useState, useEffect } from "react"
import { Button, Statistic } from 'antd'
import './index.scss'
import connect from '@/store/modules/route/connect'
const { Countdown } = Statistic
const Page401 = ({ history, userRoute = [], SYSTEM_CLEAR_LOGIN }) => {
const [time, setTime] = useState(0)
useEffect(() => {
setTime(Date.now() + 6000)
}, [])
const onFinish = () => {
if (userRoute.length)
history.replace(userRoute[0].childMenus[0].url)
else {
SYSTEM_CLEAR_LOGIN()
history.replace('/login')
}
}
return (
<div className="error-box">
<section className="error-img" style={{ backgroundImage: `url(${require('./images/401.png')})` }}></section>
<div style={{ marginBottom: 68 }}>
您没有访问该页面的权限,<Countdown value={time} format="s" onFinish={onFinish} /> 秒后自动返回{userRoute.length ? '首页' : '登录页'}。
</div>
{
userRoute.length ?
<Button type="primary" onClick={onFinish}>立即返回首页</Button> :
<Button type="primary" onClick={onFinish}>立即返回登录页</Button>
}
</div>
)
}
export default connect(Page401)