forked from Gitlink/forgeplus-react
Merge pull request '上传路由修改,上传sourcesource-map配置' (#35) from tongChong/forgeplus-react:feature_router into feature_router
This commit is contained in:
commit
9b62b3b047
|
@ -19,7 +19,8 @@ const getClientEnvironment = require("./env");
|
|||
|
||||
let publicPath = "/react/build/";
|
||||
const publicUrl = publicPath.slice(0, -1);
|
||||
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
|
||||
// const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
|
||||
const shouldUseSourceMap = process.env.NODE_ENV !== "production";
|
||||
const env = getClientEnvironment(publicPath);
|
||||
|
||||
// This is the production configuration.
|
||||
|
@ -54,7 +55,8 @@ module.exports = {
|
|||
},
|
||||
bail: true,
|
||||
mode: "production",
|
||||
devtool: false, //测试版
|
||||
// devtool: false, //测试版
|
||||
devtool: shouldUseSourceMap?'source-map':false,
|
||||
entry: [require.resolve("./polyfills"), paths.appIndexJs],
|
||||
output: {
|
||||
path: paths.appBuild,
|
||||
|
|
33
src/App.js
33
src/App.js
|
@ -114,13 +114,22 @@ class App extends Component {
|
|||
this.unlisten = this.props.history.listen((location) => {
|
||||
let newPathname = location.pathname.split('/')[1];
|
||||
if(this.state.pathName!==newPathname){
|
||||
this.setState({pathType:''});
|
||||
newPathname && this.getPathnameType(newPathname);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
if (nextProps.location.pathname.split('/')[1] !== this.props.location.pathname.split('/')[1] && nextState.pathType === this.state.pathType) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
getPathnameType = (pathname) => {
|
||||
let keyWord = ["Gitlink", "Trustie", "explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501"];
|
||||
let keyWord = ["Gitlink", "Trustie", "explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search"];
|
||||
if (!keyWord.includes(pathname)) {
|
||||
let url = `/owners/${pathname}.json`;
|
||||
axios.get(url).then((response) => {
|
||||
|
@ -308,6 +317,16 @@ class App extends Component {
|
|||
}>
|
||||
</Route> */}
|
||||
|
||||
{/*项目*/}
|
||||
<Route
|
||||
path={"/projects"}
|
||||
render={
|
||||
(props) => {
|
||||
return (<Projects {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
}>
|
||||
</Route>
|
||||
|
||||
{/* 判断为用户/组织,并进入对应页面 */}
|
||||
{
|
||||
pathType === 'User' ?
|
||||
|
@ -335,16 +354,7 @@ class App extends Component {
|
|||
/>
|
||||
}
|
||||
|
||||
{/*项目*/}
|
||||
<Route
|
||||
path={"/projects"}
|
||||
render={
|
||||
(props) => {
|
||||
return (<Projects {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
}>
|
||||
</Route>
|
||||
|
||||
|
||||
{/* 组织 */}
|
||||
<Route path={"/organize"}
|
||||
render={
|
||||
|
@ -355,7 +365,6 @@ class App extends Component {
|
|||
</Route>
|
||||
|
||||
{/* 个人主页 */}
|
||||
|
||||
<Route path="/:username"
|
||||
render={
|
||||
(props) => {
|
||||
|
|
|
@ -86,7 +86,7 @@ export function initAxiosInterceptors(props) {
|
|||
|
||||
if (response.data.status === 404) {
|
||||
let responseURL = response.request ? response.request.responseURL:'';
|
||||
if (responseURL.indexOf('/api/users/') === -1 && responseURL.indexOf('/api/organizations/') === -1) {
|
||||
if (responseURL.indexOf('/api/users/') === -1 && responseURL.indexOf('/api/organizations/') === -1 && responseURL.indexOf('/api/owners/') === -1) {
|
||||
locationurl('/nopage');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,11 @@ const ProjectIndex = Loadable({
|
|||
loading: Loading,
|
||||
});
|
||||
|
||||
const ProjectDetail = Loadable({
|
||||
loader: () => import("./Main/Detail"),
|
||||
loading: Loading,
|
||||
});
|
||||
// 项目详情放在用户和组织下作为二级菜单存在
|
||||
// const ProjectDetail = Loadable({
|
||||
// loader: () => import("./Main/Detail"),
|
||||
// loading: Loading,
|
||||
// });
|
||||
|
||||
class Index extends Component {
|
||||
|
||||
|
@ -40,35 +41,35 @@ class Index extends Component {
|
|||
<div className="newMain clearfix">
|
||||
<Switch {...this.props}>
|
||||
<Route
|
||||
path="/:projectsType/new/:OIdentifier"
|
||||
path="/projects/:projectsType/new/:OIdentifier"
|
||||
render={(props) => (
|
||||
<ProjectNew {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/:projectsType/new"
|
||||
path="/projects/:projectsType/new"
|
||||
render={(props) => (
|
||||
<ProjectNew {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/projects/new"
|
||||
path="/projects/mirror/new"
|
||||
render={(props) => (
|
||||
<ProjectNew {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
{/* <Route
|
||||
path="/:owner/:projectsId"
|
||||
render={(props) => (
|
||||
<ProjectDetail {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
{/* <Route
|
||||
path="/projects"
|
||||
></Route> */}
|
||||
<Route
|
||||
path="/explore"
|
||||
render={(props) => (
|
||||
<ProjectIndex {...this.props} {...props} />
|
||||
)}
|
||||
></Route> */}
|
||||
></Route>
|
||||
<Route
|
||||
path="/"
|
||||
render={(props) => (
|
||||
|
@ -80,16 +81,16 @@ class Index extends Component {
|
|||
);
|
||||
}
|
||||
}
|
||||
// export default withRouter(
|
||||
// ImageLayerOfCommentHOC({
|
||||
// imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
|
||||
// parentSelector: ".newMain",
|
||||
// })(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Index))))
|
||||
// );
|
||||
|
||||
export default withRouter(
|
||||
ImageLayerOfCommentHOC({
|
||||
imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
|
||||
parentSelector: ".newMain",
|
||||
})(Index)
|
||||
})(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Index))))
|
||||
);
|
||||
|
||||
// export default withRouter(
|
||||
// ImageLayerOfCommentHOC({
|
||||
// imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
|
||||
// parentSelector: ".newMain",
|
||||
// })(Index)
|
||||
// );
|
||||
|
|
|
@ -26,6 +26,11 @@ const SubDetailIndex = Loadable({
|
|||
loader: () => import("./Sub/SubDetail"),
|
||||
loading: Loading,
|
||||
});
|
||||
// forge项目详情
|
||||
const ProjectDetail = Loadable({
|
||||
loader: () => import("../Main/Detail"),
|
||||
loading: Loading,
|
||||
});
|
||||
export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
||||
((props)=>{
|
||||
return (
|
||||
|
@ -66,6 +71,15 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
|||
return <New {...props} {...p}/>
|
||||
}}
|
||||
></Route>
|
||||
|
||||
{/* 组织下的项目详情 */}
|
||||
<Route
|
||||
path="/:owner/:projectsId"
|
||||
render={(p) => (
|
||||
<ProjectDetail {...props} {...p} />
|
||||
)}
|
||||
></Route>
|
||||
|
||||
{/* 组织详情(包含组织设置) */}
|
||||
<Route
|
||||
path="/:OIdentifier"
|
||||
|
|
|
@ -11,13 +11,18 @@ const Infos = Loadable({
|
|||
loading: Loading,
|
||||
});
|
||||
//forge项目
|
||||
const Projects = Loadable({
|
||||
loader: () => import('../Index'),
|
||||
// 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) => {
|
||||
console.log(props.location.pathname);
|
||||
// 个人中心新增的二级目录都需在此添加一次。将项目放组织和个人名下后,此处根据二级目录作判断,
|
||||
let secondRouter = '';
|
||||
if (props.location.pathname) {
|
||||
secondRouter = props.location.pathname.split('/')[2];
|
||||
|
@ -25,13 +30,26 @@ export default withRouter(
|
|||
let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'watchers', 'fan_users', 'password'];
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
{/* <Route
|
||||
path="/:username"
|
||||
render={(p) => (
|
||||
secondRouter && (!userRouterArr.includes(secondRouter)) ?
|
||||
<Projects {...props} {...p} /> : <Infos {...props} {...p} />
|
||||
<ProjectDetail {...props} {...p} /> : <Infos {...props} {...p} />
|
||||
)}
|
||||
></Route>
|
||||
></Route> */}
|
||||
|
||||
{secondRouter && (!userRouterArr.includes(secondRouter)) ? <Route
|
||||
path="/:owner/:projectsId"
|
||||
render={(p) => (
|
||||
<ProjectDetail {...props} {...p} />
|
||||
)}
|
||||
></Route> : <Route
|
||||
path="/:username"
|
||||
render={(p) => (
|
||||
<Infos {...props} {...p} />
|
||||
)}
|
||||
></Route>}
|
||||
|
||||
</Switch>
|
||||
)
|
||||
}))))
|
||||
|
|
Loading…
Reference in New Issue