From 559b797c2ebcb6f8d9e490adb01bbc9b6fdce002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Thu, 2 Sep 2021 13:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1=E5=B8=A6?= =?UTF-8?q?=E6=9D=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 54 ++++++++++++++------------- src/forge/Index.js | 6 --- src/forge/Settings/Setting.js | 6 +-- src/forge/Team/Group/GroupDetails.jsx | 4 +- src/forge/Team/Index.jsx | 8 ++++ src/forge/Team/List.jsx | 4 +- src/forge/Team/New.jsx | 1 - src/forge/users/Index.jsx | 21 +++++++---- 8 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/App.js b/src/App.js index d9e1a3ef1..aae03b9de 100644 --- a/src/App.js +++ b/src/App.js @@ -91,6 +91,10 @@ const ProjectIndex = Loadable({ loader: () => import("./forge/Index"), loading: Loading, }); + +// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。 +const keyWord = ["explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search"]; + class App extends Component { constructor(props) { super(props); @@ -101,7 +105,7 @@ class App extends Component { occupation: 0, mygetHelmetapi: null, pathType: null, - pathName:'', + pathName: '', } } @@ -113,14 +117,15 @@ 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:''}); + if (this.state.pathName !== newPathname) { + this.setState({ pathType: '' }); newPathname && this.getPathnameType(newPathname); } }); } shouldComponentUpdate(nextProps, nextState) { + // (!keyWord.includes(this.props.location.pathname.split('/')[1])) && if (nextProps.location.pathname.split('/')[1] !== this.props.location.pathname.split('/')[1] && nextState.pathType === this.state.pathType) { return false; } else { @@ -129,17 +134,21 @@ class App extends Component { } 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", "search"]; if (!keyWord.includes(pathname)) { let url = `/owners/${pathname}.json`; axios.get(url).then((response) => { if (response && response.status === 200) { this.setState({ pathType: response.data.type || '404', - pathName:pathname, + pathName: pathname, }) } }); + }else{ + this.setState({ + pathType: pathname, + pathName: pathname, + }); } } @@ -277,7 +286,7 @@ class App extends Component { } }> - + - {/* { - return () - } - }> - */} - {/*项目*/} ) } }> - : pathType === '404' ? : ( - personal && personal.length > 0 ? - - : - - ) - } - /> + : pathType === '404' ? : + ( + personal && personal.length > 0 ? + + : + + ) + } + /> + // } - + {/* 组织 */} )} > - ( - - )} - > ); diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index a9e5cc44d..9b2df136d 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -179,11 +179,9 @@ class Setting extends Component { content: 该操作无法撤销!且将会一并删除相关的易修、合并请求、工作流、里程碑、动态等数据。
是否确认删除 {owner}/{projectName}({projectsId})
, onOk: () => { const url = `/${owner}/${projectsId}.json`; - axios - .delete(url) - .then((result) => { + axios.delete(url).then((result) => { this.props.showNotification("仓库删除成功!"); - this.props.history.push("/projects"); + this.props.history.push(`/${owner}`); }) .catch((error) => { console.log(error); diff --git a/src/forge/Team/Group/GroupDetails.jsx b/src/forge/Team/Group/GroupDetails.jsx index 64b52964f..b35132bcf 100644 --- a/src/forge/Team/Group/GroupDetails.jsx +++ b/src/forge/Team/Group/GroupDetails.jsx @@ -87,9 +87,9 @@ export default ((props) => { if (username) { const url = `/organizations/${OIdentifier}/teams/${groupId}/team_users/quit.json`; axios.delete(url).then((result) => { - if (result && result.data) { + if (result && result.message==='success') { props.showNotification(`已成功退出团队!`); - props.history.push(`/${OIdentifier}`); + props.history.push(`/${username}`); } }).catch((error) => { }); } diff --git a/src/forge/Team/Index.jsx b/src/forge/Team/Index.jsx index e3266c88d..4dfa85f4d 100644 --- a/src/forge/Team/Index.jsx +++ b/src/forge/Team/Index.jsx @@ -72,6 +72,14 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC( }} >
+ {/* 组织详情(包含组织设置) */} + ( + + )} + > + {/* 组织下的项目详情 */} - 新建托管项目 - 新建镜像项目 + 新建托管项目 + 新建镜像项目 ) diff --git a/src/forge/Team/New.jsx b/src/forge/Team/New.jsx index b39711338..414a8d158 100644 --- a/src/forge/Team/New.jsx +++ b/src/forge/Team/New.jsx @@ -145,7 +145,6 @@ export default Form.create()(

-

) diff --git a/src/forge/users/Index.jsx b/src/forge/users/Index.jsx index 066d87444..7e209113e 100644 --- a/src/forge/users/Index.jsx +++ b/src/forge/users/Index.jsx @@ -22,21 +22,26 @@ const ProjectDetail = Loadable({ }); 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 ( - {/* ( - secondRouter && (!userRouterArr.includes(secondRouter)) ? - : - )} - > */} {secondRouter && (!userRouterArr.includes(secondRouter)) ? : ( - + )} >}