index.js 1.13 KB
Newer Older
偏右's avatar
偏右 committed
1
import React, { createElement } from 'react';
2 3 4 5 6
import classNames from 'classnames';
import { Button } from 'antd';
import config from './typeConfig';
import styles from './index.less';

ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
7
const Exception = ({ className, linkElement = 'a', type, title, desc, img, actions, ...rest }) => {
8 9 10
  const pageType = type in config ? type : '404';
  const clsString = classNames(styles.exception, className);
  return (
11
    <div className={clsString} {...rest}>
12
      <div className={styles.imgBlock}>
ddcat1115's avatar
ddcat1115 committed
13 14 15 16
        <div
          className={styles.imgEle}
          style={{ backgroundImage: `url(${img || config[pageType].img})` }}
        />
17 18 19 20 21
      </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
22 23 24 25
          {actions ||
            createElement(
              linkElement,
              {
偏右's avatar
偏右 committed
26 27
                to: '/',
                href: '/',
jim's avatar
jim committed
28 29 30
              },
              <Button type="primary">θΏ”ε›žι¦–ι‘΅</Button>
            )}
31 32 33 34 35
        </div>
      </div>
    </div>
  );
};
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
36 37

export default Exception;