Skip to content

Commit

Permalink
refactor: 将顶部进度条的实现放在Loading组件中
Browse files Browse the repository at this point in the history
  • Loading branch information
NLRX-WJC committed May 19, 2020
1 parent 5e8a1a8 commit 1b9bf1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
28 changes: 20 additions & 8 deletions src/components/Loading/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import React from "react";
import React, { Component } from "react";
import { Spin } from "antd";
import NProgress from "nprogress"; // progress bar
import "nprogress/nprogress.css"; // progress bar style

const Loading = () => {
return (
<div className="app-container">
<Spin />
</div>
);
};
NProgress.configure({ showSpinner: false }); // NProgress Configuration

class Loading extends Component {
componentDidMount() {
NProgress.start();
}
componentWillUnmount() {
NProgress.done();
}
render() {
return (
<div className="app-container">
<Spin />
</div>
);
}
}

export default Loading;
6 changes: 0 additions & 6 deletions src/views/layout/Content/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import { Redirect, withRouter, Route, Switch } from "react-router-dom";
import DocumentTitle from "react-document-title";
import { connect } from "react-redux";
import { CSSTransition, TransitionGroup } from "react-transition-group";
import NProgress from "nprogress"; // progress bar
import "nprogress/nprogress.css"; // progress bar style

import { Layout } from "antd";
import { getMenuItemInMenuListByProperty } from "@/utils";
import routeList from "@/config/routeMap";
import menuList from "@/config/menuConfig";
const { Content } = Layout;
NProgress.configure({ showSpinner: false }); // NProgress Configuration

const getPageTitle = (menuList, pathname) => {
let title = "Ant Design Pro";
Expand All @@ -38,8 +34,6 @@ const LayoutContent = (props) => {
timeout={500}
classNames="fade"
exit={false}
onEnter={() => NProgress.start()}
onEntered={() => NProgress.done()}
>
<Switch location={location}>
<Redirect exact from="/" to="/dashboard" />
Expand Down

0 comments on commit 1b9bf1a

Please sign in to comment.