forked from Gitlink/forgeplus-react
61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
import React from 'react';
|
||
import { Route, Switch } from "react-router-dom";
|
||
import Loadable from "react-loadable";
|
||
import Loading from "../../Loading";
|
||
import { withRouter } from "react-router";
|
||
import { SnackbarHOC } from "educoder";
|
||
import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC";
|
||
import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC";
|
||
const Infos = Loadable({
|
||
loader: () => import("./Infos"),
|
||
loading: Loading,
|
||
});
|
||
//forge项目
|
||
// const Projects = Loadable({
|
||
// loader: () => import('../Index'),
|
||
// loading: Loading,
|
||
// })
|
||
// forge项目详情
|
||
const ProjectDetail = Loadable({
|
||
loader: () => import("../Main/Detail"),
|
||
loading: Loading,
|
||
});
|
||
export default withRouter(
|
||
(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC((props) => {
|
||
|
||
// 个人中心新增的二级目录都需在此添加一次。将项目放组织和个人名下后,此处根据二级目录作判断,
|
||
let secondRouter = '';
|
||
let firstRouter = '';
|
||
if (props.location.pathname) {
|
||
firstRouter =props.location.pathname.split('/')[1];
|
||
secondRouter = props.location.pathname.split('/')[2];
|
||
}
|
||
// 如果是explore,把所有路由相关的都改成当前登录人;
|
||
let changePathProps={...props};
|
||
if(firstRouter==='explore'){
|
||
let login=props.current_user.login;
|
||
changePathProps.match.path=`/${login}`;
|
||
changePathProps.match.url=`/${login}`;
|
||
changePathProps.location.pathname=`/${login}`;
|
||
changePathProps.history.location.pathname=`/${login}`;
|
||
}
|
||
let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'watchers', 'fan_users', 'password'];
|
||
return (
|
||
<Switch>
|
||
|
||
{secondRouter && (!userRouterArr.includes(secondRouter)) ? <Route
|
||
path="/:owner/:projectsId"
|
||
render={(p) => (
|
||
<ProjectDetail {...props} {...p} />
|
||
)}
|
||
></Route> : <Route
|
||
path="/:username"
|
||
render={(p) => (
|
||
<Infos {...changePathProps} {...p} />
|
||
)}
|
||
></Route>}
|
||
|
||
</Switch>
|
||
)
|
||
}))))
|
||
) |