-
Notifications
You must be signed in to change notification settings - Fork 0
/
_error.js
72 lines (67 loc) · 1.91 KB
/
_error.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React,{Component} from 'react';
import Head from 'next/head';
import Link from 'next/link'
import {
Layout, Menu, Breadcrumb, Row, Col,
List, Avatar, Icon, Pagination, Alert,
Input, Button, Radio, Tooltip, Spin
} from 'antd'
import styles from 'antd/dist/antd.less';
// import {COMMON_TITLE, ABOUT_TXT, MY_BLOG} from '../config/constantsData';
const {Content} = Layout;
class Error extends Component {
static getInitialProps({ res, err }) {
const statusCode = res ? res.statusCode : err ? err.statusCode : null;
return { statusCode }
}
constructor() {
super();
}
render(){
return (
<div>
<Head>
<title>error-{this.props.statusCode}</title>
</Head>
<Layout>
<Content style={{padding: '0 50px'}}>
<div className="_error" style={{background: '#fff', padding: 24, minHeight: 380}}>
<p className="cont">
{this.props.statusCode
?
<div>
An error {this.props.statusCode} occurred on server
<Link href='/'>
<a>返回首页</a>
</Link>
<p>
<Link href='/'>
<a>返回首页</a>
</Link>
<Link href="/about">
<a>here</a>
</Link>
</p>
</div>
: 'An error occurred on client'}
</p>
</div>
</Content>
</Layout>
<style jsx>{`
._error{
position:relative;
}
.cont{
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%,-50%,0);
text-align: center;
}
`}</style>
</div>
);
}
}
export default Error;