forgeplus-react/src/forge/users/Index.jsx

61 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>
)
}))))
)