index.js 1.07 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';

偏右's avatar
偏右 committed
7
export default ({ 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}>
偏右's avatar
偏右 committed
22 23 24 25 26 27 28
          {
            actions ||
              createElement(linkElement, {
                to: '/',
                href: '/',
              }, <Button type="primary">θΏ”ε›žι¦–ι‘΅</Button>)
          }
29 30 31 32 33
        </div>
      </div>
    </div>
  );
};