|
|
@@ -1,40 +1,57 @@
|
|
|
import React, { createElement } from 'react';
|
|
|
-import { injectIntl, FormattedMessage } from 'react-intl';
|
|
|
import classNames from 'classnames';
|
|
|
import { Button } from 'antd';
|
|
|
import config from './typeConfig';
|
|
|
import styles from './index.less';
|
|
|
|
|
|
-const Exception = ({ className, linkElement = 'a', type, title, desc, img, actions, ...rest }) => {
|
|
|
- const pageType = type in config ? type : '404';
|
|
|
- const clsString = classNames(styles.exception, className);
|
|
|
- return (
|
|
|
- <div className={clsString} {...rest}>
|
|
|
- <div className={styles.imgBlock}>
|
|
|
- <div
|
|
|
- className={styles.imgEle}
|
|
|
- style={{ backgroundImage: `url(${img || config[pageType].img})` }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className={styles.content}>
|
|
|
- <h1>{title || config[pageType].title}</h1>
|
|
|
- <div className={styles.desc}>{desc || config[pageType].desc}</div>
|
|
|
- <div className={styles.actions}>
|
|
|
- {actions ||
|
|
|
- createElement(
|
|
|
- linkElement,
|
|
|
- {
|
|
|
- to: '/',
|
|
|
- href: '/',
|
|
|
- },
|
|
|
- <Button type="primary">
|
|
|
- <FormattedMessage id="app.exception.back" defaultMessage="Back to home" />
|
|
|
- </Button>
|
|
|
- )}
|
|
|
+class Excrption extends React.PureComponent {
|
|
|
+ static defaultProps = {
|
|
|
+ backText: 'back to home',
|
|
|
+ };
|
|
|
+ constructor(props) {
|
|
|
+ super(props);
|
|
|
+ this.state = {};
|
|
|
+ }
|
|
|
+ render() {
|
|
|
+ const {
|
|
|
+ className,
|
|
|
+ backText,
|
|
|
+ linkElement = 'a',
|
|
|
+ type,
|
|
|
+ title,
|
|
|
+ desc,
|
|
|
+ img,
|
|
|
+ actions,
|
|
|
+ ...rest
|
|
|
+ } = this.props;
|
|
|
+ const pageType = type in config ? type : '404';
|
|
|
+ const clsString = classNames(styles.exception, className);
|
|
|
+ return (
|
|
|
+ <div className={clsString} {...rest}>
|
|
|
+ <div className={styles.imgBlock}>
|
|
|
+ <div
|
|
|
+ className={styles.imgEle}
|
|
|
+ style={{ backgroundImage: `url(${img || config[pageType].img})` }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className={styles.content}>
|
|
|
+ <h1>{title || config[pageType].title}</h1>
|
|
|
+ <div className={styles.desc}>{desc || config[pageType].desc}</div>
|
|
|
+ <div className={styles.actions}>
|
|
|
+ {actions ||
|
|
|
+ createElement(
|
|
|
+ linkElement,
|
|
|
+ {
|
|
|
+ to: '/',
|
|
|
+ href: '/',
|
|
|
+ },
|
|
|
+ <Button type="primary">{backText}</Button>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- );
|
|
|
-};
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-export default injectIntl(Exception);
|
|
|
+export default Excrption;
|