index.js 1.29 KB
Newer Older
偏右's avatar
偏右 committed
1
import React, { createElement } from 'react';
张秀玲's avatar
张秀玲 committed
2
import { injectIntl, FormattedMessage } from 'react-intl';
3 4 5 6 7
import classNames from 'classnames';
import { Button } from 'antd';
import config from './typeConfig';
import styles from './index.less';

ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
8
const Exception = ({ className, linkElement = 'a', type, title, desc, img, actions, ...rest }) => {
9 10 11
  const pageType = type in config ? type : '404';
  const clsString = classNames(styles.exception, className);
  return (
12
    <div className={clsString} {...rest}>
13
      <div className={styles.imgBlock}>
ddcat1115's avatar
ddcat1115 committed
14 15 16 17
        <div
          className={styles.imgEle}
          style={{ backgroundImage: `url(${img || config[pageType].img})` }}
        />
18 19 20 21 22
      </div>
      <div className={styles.content}>
        <h1>{title || config[pageType].title}</h1>
        <div className={styles.desc}>{desc || config[pageType].desc}</div>
        <div className={styles.actions}>
jim's avatar
jim committed
23 24 25 26
          {actions ||
            createElement(
              linkElement,
              {
偏右's avatar
偏右 committed
27 28
                to: '/',
                href: '/',
jim's avatar
jim committed
29
              },
张秀玲's avatar
张秀玲 committed
30 31 32
              <Button type="primary">
                <FormattedMessage id="app.exception.back" defaultMessage="Back to home" />
              </Button>
jim's avatar
jim committed
33
            )}
34 35 36 37 38
        </div>
      </div>
    </div>
  );
};
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
39

张秀玲's avatar
张秀玲 committed
40
export default injectIntl(Exception);