| /** |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| |
| import React, { createElement } from 'react'; |
| import classNames from 'classnames'; |
| import { Button } from 'antd'; |
| import config from './typeConfig'; |
| import styles from './index.less'; |
| |
| export default ({ 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">返回首页</Button>) |
| } |
| </div> |
| </div> |
| </div> |
| ); |
| }; |