forgeplus-react/src/forge/Index.js

100 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-06-02 18:54:46 +08:00
import React, { Component } from "react";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import { Route, Switch } from "react-router-dom";
import { withRouter } from "react-router";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import { SnackbarHOC } from "educoder";
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
2020-06-22 14:07:06 +08:00
import "./css/index.scss";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import Loadable from "react-loadable";
import Loading from "../Loading";
import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC";
2020-03-16 14:12:11 +08:00
2020-03-16 14:12:11 +08:00
const ProjectNew = Loadable({
2021-09-02 17:20:26 +08:00
loader: () => import("./New/Index"),
2020-05-11 14:18:32 +08:00
loading: Loading,
2020-06-02 18:54:46 +08:00
});
2020-03-16 14:12:11 +08:00
const ProjectIndex = Loadable({
2020-06-02 18:54:46 +08:00
loader: () => import("./Main/Index"),
2020-05-11 14:18:32 +08:00
loading: Loading,
2020-06-02 18:54:46 +08:00
});
2020-03-16 14:12:11 +08:00
// 项目详情放在用户和组织下作为二级菜单存在
// const ProjectDetail = Loadable({
// loader: () => import("./Main/Detail"),
// loading: Loading,
// });
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
class Index extends Component {
2021-09-02 17:20:26 +08:00
componentDidUpdate = () => {
this.props.history.listen(() => {
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
window.scrollTo(0, 0)
}
})
}
2020-05-11 14:18:32 +08:00
render() {
2021-09-03 09:23:12 +08:00
2020-05-11 14:18:32 +08:00
return (
2020-03-16 14:12:11 +08:00
<div className="newMain clearfix">
<Switch {...this.props}>
2021-01-28 11:48:21 +08:00
<Route
path="/projects/:projectsType/new/:OIdentifier"
2021-01-28 11:48:21 +08:00
render={(props) => (
<ProjectNew {...this.props} {...props} />
)}
></Route>
2020-06-02 18:54:46 +08:00
<Route
path="/projects/:projectsType/new"
2020-06-02 18:54:46 +08:00
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectNew {...this.props} {...props} />
2021-03-25 22:00:01 +08:00
)}
></Route>
<Route
path="/projects/mirror/new"
2021-03-25 22:00:01 +08:00
render={(props) => (
<ProjectNew {...this.props} {...props} />
2020-06-02 18:54:46 +08:00
)}
2020-03-16 14:12:11 +08:00
></Route>
{/* <Route
2021-09-01 09:33:22 +08:00
path="/:owner/:projectsId"
2020-06-02 18:54:46 +08:00
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectDetail {...this.props} {...props} />
2020-06-02 18:54:46 +08:00
)}
></Route> */}
<Route
path="/explore"
2020-06-02 18:54:46 +08:00
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectIndex {...this.props} {...props} />
)}
></Route>
2021-09-03 09:23:12 +08:00
2021-09-02 17:20:26 +08:00
<Route
path="/"
render={(props) => (
<ProjectIndex {...this.props} {...props} />
)}
></Route>
2020-03-16 14:12:11 +08:00
</Switch>
</div>
2020-06-02 18:54:46 +08:00
);
2020-03-16 14:12:11 +08:00
}
}
2020-06-02 18:54:46 +08:00
export default withRouter(
ImageLayerOfCommentHOC({
imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
parentSelector: ".newMain",
})(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Index))))
2020-06-02 18:54:46 +08:00
);
// export default withRouter(
// ImageLayerOfCommentHOC({
// imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
// parentSelector: ".newMain",
// })(Index)
// );