guards.js 637 Bytes
import React from 'react'
import BreadCrumbs from '../components/BreadCrumbs'
import { show, hide } from 'loading-bar'

// 路由守卫
export const Guards = (Page, isBread = false) => {
    return class extends React.Component {

        /** 进入页面 */
        componentDidMount() {
            hide()
        }
        /** 离开页面 */
        componentWillUnmount() {
            show()
        }

        render() {
            return (
                <>
                    { isBread ? <BreadCrumbs {...this.props} /> : null}
                    <Page {...this.props} />
                </>
            )
        }
    }
}