From e606147d03468be0945b75fd0163be1c8ea89897 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, 26 Aug 2021 14:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E7=BB=87=E5=92=8C?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=9A=84=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 75 +++++++++++++++++--- src/forge/Main/Detail.js | 4 +- src/forge/Main/IndexItem.js | 2 +- src/forge/Settings/CollaboratorGroup.jsx | 2 +- src/forge/Team/Group/GroupDetailSetting.jsx | 16 ++--- src/forge/Team/Group/GroupDetails.jsx | 4 +- src/forge/Team/Group/GroupForm.jsx | 8 +-- src/forge/Team/Index.jsx | 10 +-- src/forge/Team/New.jsx | 2 +- src/forge/Team/RightBox.jsx | 8 +-- src/forge/Team/Setting/TeamSettingCommon.jsx | 2 +- src/forge/Team/Setting/TeamSettingIndex.jsx | 22 +++--- src/forge/Team/Sub/Detail.jsx | 20 +++--- src/forge/Team/Sub/SubDetail.jsx | 12 ++-- src/forge/Team/TeamGroupItems.jsx | 6 +- src/forge/users/Index.jsx | 3 +- src/forge/users/Infos.js | 3 +- src/forge/users/Team-item.jsx | 2 +- 18 files changed, 129 insertions(+), 72 deletions(-) diff --git a/src/App.js b/src/App.js index e6f1fc3e8..17be118b0 100644 --- a/src/App.js +++ b/src/App.js @@ -100,6 +100,27 @@ class App extends Component { mydisplay: false, occupation: 0, mygetHelmetapi: null, + pathType: null, + } + } + + UNSAFE_componentWillMount() { + initAxiosInterceptors(this.props); + let pathname = window.location.pathname ? window.location.pathname.split('/')[1] : ''; + pathname && this.getPathnameType(pathname); + } + + getPathnameType = (pathname) => { + let keyWord = ["Gitlink", "Trustie", "explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email",]; + 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' + }) + } + }); } } @@ -119,7 +140,7 @@ class App extends Component { componentDidMount() { document.title = "loading..."; - initAxiosInterceptors(this.props); + this.getAppdata(); window.addEventListener('error', (event) => { @@ -196,7 +217,7 @@ class App extends Component { }; render() { - const { mygetHelmetapi } = this.state; + const { mygetHelmetapi, pathType } = this.state; let personal = mygetHelmetapi && mygetHelmetapi.personal; return ( @@ -251,27 +272,61 @@ class App extends Component { - { - return () - } - }> - + {/*404*/} {/* 查询 */} + ( + personal && personal.length > 0 ? + + : + + ) + } + /> + + {/* 判断为用户/组织,并进入对应页面 */} + { + pathType === 'User' ? + { + return () + } + } + /> : pathType === 'Organization' ? { + return () + } + }> + : pathType === '404' ? : + } + + + {/* 组织 */} + {/* { + return () + } + }> + */} {/* 个人主页 */} - { return () } }> + ( diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index f01ef2d3e..583b4db3d 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -417,7 +417,7 @@ class Detail extends Component { return forked_from_project_id && fork_info ?
复刻自 - {fork_info.fork_project_user_name} + {fork_info.fork_project_user_name} / {fork_info.fork_form_name}
: "" @@ -453,7 +453,7 @@ class Detail extends Component {
{project && project.author && - {project.author.name} + {project.author.name} } / {projectDetail && projectDetail.name} diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index fcfa2d2af..4e83e4393 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -28,7 +28,7 @@ class IndexItem extends Component { : - + } diff --git a/src/forge/Settings/CollaboratorGroup.jsx b/src/forge/Settings/CollaboratorGroup.jsx index c6ab6ffbc..3afd9e03e 100644 --- a/src/forge/Settings/CollaboratorGroup.jsx +++ b/src/forge/Settings/CollaboratorGroup.jsx @@ -77,7 +77,7 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) { title: "团队名", dataIndex: "name", render: (value, item) => { - return {value}; + return {value}; }, }, { diff --git a/src/forge/Team/Group/GroupDetailSetting.jsx b/src/forge/Team/Group/GroupDetailSetting.jsx index fa060ee33..e8be37228 100644 --- a/src/forge/Team/Group/GroupDetailSetting.jsx +++ b/src/forge/Team/Group/GroupDetailSetting.jsx @@ -26,18 +26,18 @@ export default (props)=>{ function returnActive (pathname){ let a = 0; - if(pathname === `/organize/${OIdentifier}/group/${groupId}/setting/member`){ + if(pathname === `/${OIdentifier}/group/${groupId}/setting/member`){ a = 1; - }else if(pathname === `/organize/${OIdentifier}/group/${groupId}/setting/project`){ + }else if(pathname === `/${OIdentifier}/group/${groupId}/setting/project`){ a = 2; } return a; } const active = returnActive(pathname); const array = {list:[ - {name:'基本设置',icon:"icon-base",href:`/organize/${OIdentifier}/group/${groupId}/setting`}, - {name:'团队成员管理',icon:"icon-zuzhichengyuan",href:`/organize/${OIdentifier}/group/${groupId}/setting/member`}, - {name:'团队项目管理',icon:"icon-zuzhixiangmu",href:`/organize/${OIdentifier}/group/${groupId}/setting/project`}, + {name:'基本设置',icon:"icon-base",href:`/${OIdentifier}/group/${groupId}/setting`}, + {name:'团队成员管理',icon:"icon-zuzhichengyuan",href:`/${OIdentifier}/group/${groupId}/setting/member`}, + {name:'团队项目管理',icon:"icon-zuzhixiangmu",href:`/${OIdentifier}/group/${groupId}/setting/project`}, ], active } @@ -51,19 +51,19 @@ export default (props)=>{ ( )} > ( )} > ( )} diff --git a/src/forge/Team/Group/GroupDetails.jsx b/src/forge/Team/Group/GroupDetails.jsx index 75183f354..64b52964f 100644 --- a/src/forge/Team/Group/GroupDetails.jsx +++ b/src/forge/Team/Group/GroupDetails.jsx @@ -89,7 +89,7 @@ export default ((props) => { axios.delete(url).then((result) => { if (result && result.data) { props.showNotification(`已成功退出团队!`); - props.history.push(`/organize/${OIdentifier}`); + props.history.push(`/${OIdentifier}`); } }).catch((error) => { }); } @@ -119,7 +119,7 @@ export default ((props) => {

管理员团队对 所有仓库 具有操作权限,且对组织具有 管理员权限

此外,该团队拥有了 创建仓库 的权限:成员可以在组织中创建新的仓库。

- {group.is_admin ? : ""} + {group.is_admin ? : ""}
: diff --git a/src/forge/Team/Group/GroupForm.jsx b/src/forge/Team/Group/GroupForm.jsx index 2eb8540f9..108ef2400 100644 --- a/src/forge/Team/Group/GroupForm.jsx +++ b/src/forge/Team/Group/GroupForm.jsx @@ -76,7 +76,7 @@ export default Form.create()( }).then(result => { if (result && result.data) { showNotification("基本设置更新成功!"); - history.push(`/organize/${OIdentifier}/group/${groupId}`); + history.push(`/${OIdentifier}/group/${groupId}`); } }).catch(error => { }) } else { @@ -86,7 +86,7 @@ export default Form.create()( }).then(result => { if (result && result.data) { showNotification("团队创建成功!"); - history.push(`/organize/${OIdentifier}/group/${result.data.id}`); + history.push(`/${OIdentifier}/group/${result.data.id}`); } }).catch(error => { }) } @@ -134,9 +134,9 @@ export default Form.create()( function cancelEdit(){ if(groupId){ - history.push(`/organize/${OIdentifier}/group/${groupId}`); + history.push(`/${OIdentifier}/group/${groupId}`); }else{ - history.push(`/organize/${OIdentifier}`); + history.push(`/${OIdentifier}`); } } diff --git a/src/forge/Team/Index.jsx b/src/forge/Team/Index.jsx index fd4afedf6..2b75a35ef 100644 --- a/src/forge/Team/Index.jsx +++ b/src/forge/Team/Index.jsx @@ -33,28 +33,28 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC( {/* 组织团队-设置 */} { return }} > {/* 组织团队-新建 */} { return }} > {/* 组织团队-子级(包含组织团队列表) */} { return }} > {/* 组织成员 */} { return }} @@ -68,7 +68,7 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC( > {/* 组织详情(包含组织设置) */} ( )} diff --git a/src/forge/Team/New.jsx b/src/forge/Team/New.jsx index 1f06dc22f..414a8d158 100644 --- a/src/forge/Team/New.jsx +++ b/src/forge/Team/New.jsx @@ -49,7 +49,7 @@ export default Form.create()( }).then(result=>{ if(result && result.data){ showNotification("组织创建成功!"); - history.push(`/organize/${result.data.name}`); + history.push(`/${result.data.name}`); } }).catch(error=>{}) } diff --git a/src/forge/Team/RightBox.jsx b/src/forge/Team/RightBox.jsx index 0603a4548..5425e6222 100644 --- a/src/forge/Team/RightBox.jsx +++ b/src/forge/Team/RightBox.jsx @@ -67,7 +67,7 @@ function RightBox({ OIdentifier , history , admin }) {
{ memberData && memberData.organization_users && memberData.organization_users.length>0 ? - + { memberData.organization_users.map((item,key)=>{ return( @@ -87,8 +87,8 @@ function RightBox({ OIdentifier , history , admin }) { history.push(`/organize/${OIdentifier}/group/new`)}>新建团队} - url={`/organize/${OIdentifier}/group`} + bottom={admin && } + url={`/${OIdentifier}/group`} > { groupData && groupData.teams && groupData.teams.length>0? @@ -97,7 +97,7 @@ function RightBox({ OIdentifier , history , admin }) { return(
- {item.name} + {item.name} {item.num_users}名成员 {item.num_projects}个仓库 diff --git a/src/forge/Team/Setting/TeamSettingCommon.jsx b/src/forge/Team/Setting/TeamSettingCommon.jsx index 5be03db09..441743593 100644 --- a/src/forge/Team/Setting/TeamSettingCommon.jsx +++ b/src/forge/Team/Setting/TeamSettingCommon.jsx @@ -62,7 +62,7 @@ export default Form.create()( showNotification("组织信息更新成功!"); if(values.name !== organizeDetail.name){ console.log("false111"); - history.push(`/organize/${values.name}/setting`); + history.push(`/${values.name}/setting`); } updateFunc && updateFunc(values.name,values.description); } diff --git a/src/forge/Team/Setting/TeamSettingIndex.jsx b/src/forge/Team/Setting/TeamSettingIndex.jsx index 718f5b5f0..462a92d10 100644 --- a/src/forge/Team/Setting/TeamSettingIndex.jsx +++ b/src/forge/Team/Setting/TeamSettingIndex.jsx @@ -30,21 +30,21 @@ export default (( props )=>{ function returnActive (pathname){ let a = 0; - if(pathname === `/organize/${OIdentifier}/setting/member`){ + if(pathname === `/${OIdentifier}/setting/member`){ a = 1; - }else if(pathname === `/organize/${OIdentifier}/setting/group`){ + }else if(pathname === `/${OIdentifier}/setting/group`){ a = 2; - }else if(pathname === `/organize/${OIdentifier}/setting/hooks`){ + }else if(pathname === `/${OIdentifier}/setting/hooks`){ a = 3; } return a; } const active = returnActive(pathname); const array = {list:[ - {name:'基本设置',icon:"icon-base",href:`/organize/${OIdentifier}/setting`}, - {name:'组织成员管理',icon:"icon-zuzhichengyuan",href:`/organize/${OIdentifier}/setting/member`}, - {name:'组织团队管理',icon:"icon-zuzhixiangmu",href:`/organize/${OIdentifier}/setting/group`}, - // {name:'管理web钩子',icon:"icon-zhongqingdianxinicon10",href:`/organize/${OIdentifier}/setting/hooks`} + {name:'基本设置',icon:"icon-base",href:`/${OIdentifier}/setting`}, + {name:'组织成员管理',icon:"icon-zuzhichengyuan",href:`/${OIdentifier}/setting/member`}, + {name:'组织团队管理',icon:"icon-zuzhixiangmu",href:`/${OIdentifier}/setting/group`}, + // {name:'管理web钩子',icon:"icon-zhongqingdianxinicon10",href:`/${OIdentifier}/setting/hooks`} ], active } @@ -58,25 +58,25 @@ export default (( props )=>{
( )} > ( )} > ( )} > ( )} diff --git a/src/forge/Team/Sub/Detail.jsx b/src/forge/Team/Sub/Detail.jsx index 6e048a059..36d8a9160 100644 --- a/src/forge/Team/Sub/Detail.jsx +++ b/src/forge/Team/Sub/Detail.jsx @@ -38,12 +38,12 @@ function Detail(props){ // 设置页面:顶部不需要设置按钮了 useEffect(()=>{ if(pathname){ - if(pathname.indexOf(`/organize/${OIdentifier}/setting`)>-1){ + if(pathname.indexOf(`/${OIdentifier}/setting`)>-1){ setFlag(false); }else{ setFlag(true); } - if(pathname.indexOf(`/organize/${OIdentifier}/group`)>-1 || pathname.indexOf(`/organize/${OIdentifier}/member`)>-1){ + if(pathname.indexOf(`/${OIdentifier}/group`)>-1 || pathname.indexOf(`/${OIdentifier}/member`)>-1){ setButtonflagFlag(true); }else{ setButtonflagFlag(false); @@ -84,12 +84,12 @@ function Detail(props){ rightBtn={ {flag && !buttonflag && detail.is_admin ? - 设置 + 设置 :""} {buttonflag && - 组织成员{detail.num_users && {detail.num_users}} - 组织团队{detail.num_teams &&{detail.num_teams}} + 组织成员{detail.num_users && {detail.num_users}} + 组织团队{detail.num_teams &&{detail.num_teams}} } @@ -112,33 +112,33 @@ function Detail(props){ {/* 组织团队-详情 */} { return }} > {/* 组织成员 */} { return }} > {/* 组织团队 */} { return }} > { return }} > { return }} diff --git a/src/forge/Team/Sub/SubDetail.jsx b/src/forge/Team/Sub/SubDetail.jsx index 7b653c55c..94ac6a2a0 100644 --- a/src/forge/Team/Sub/SubDetail.jsx +++ b/src/forge/Team/Sub/SubDetail.jsx @@ -22,7 +22,7 @@ export default ((props)=>{ // 设置页面:顶部不需要设置按钮了 useEffect(()=>{ if(pathname){ - if(pathname.indexOf(`/organize/${OIdentifier}/group/${groupId}/setting`)>-1){ + if(pathname.indexOf(`/${OIdentifier}/group/${groupId}/setting`)>-1){ setFlag(false); }else{ setFlag(true); @@ -48,19 +48,19 @@ export default ((props)=>{
- {OIdentifier} + {OIdentifier} {detail ? detail.name : "新建团队"}
{ detail && - 组织成员{detail.num_users && {detail.num_users}} - 组织团队{detail.num_teams &&{detail.num_teams}} + 组织成员{detail.num_users && {detail.num_users}} + 组织团队{detail.num_teams &&{detail.num_teams}} } desc={!flag && detail.description} @@ -69,7 +69,7 @@ export default ((props)=>{ {/* 组织团队-设置 */} { return }} diff --git a/src/forge/Team/TeamGroupItems.jsx b/src/forge/Team/TeamGroupItems.jsx index e96a310d3..b482942c7 100644 --- a/src/forge/Team/TeamGroupItems.jsx +++ b/src/forge/Team/TeamGroupItems.jsx @@ -53,7 +53,7 @@ function TeamGroupItems({organizeDetail,limit, count , history}){ } // 团队设置 function toGroupSetting(id){ - history.push(`/organize/${organizeDetail && organizeDetail.name}/group/${id}/setting`); + history.push(`/${organizeDetail && organizeDetail.name}/group/${id}/setting`); } // 解散团队 function disMissGroup(id){ @@ -75,7 +75,7 @@ function TeamGroupItems({organizeDetail,limit, count , history}){ return(

- {item.nickname} + {item.nickname} { item.is_admin && item.authorize!=="owner" && disMissGroup(item.id)}>解散团队} { item.is_member && } @@ -89,7 +89,7 @@ function TeamGroupItems({organizeDetail,limit, count , history}){ k < count ? : k === count ? - + :"" ) }) diff --git a/src/forge/users/Index.jsx b/src/forge/users/Index.jsx index ce5aeda71..c7f6fe924 100644 --- a/src/forge/users/Index.jsx +++ b/src/forge/users/Index.jsx @@ -12,11 +12,12 @@ const Infos = Loadable({ }); export default withRouter( (CNotificationHOC()(SnackbarHOC()(TPMIndexHOC((props)=>{ + console.log(props); return(

( )} diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index a588cb8b2..bcd011136 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -72,6 +72,7 @@ class Infos extends Component { renderPath=(pathname)=>{ const { username } = this.props.match.params; + console.log(username); if(pathname === `/users/${username}`){ this.setState({menuKey:"0",route_type:undefined}); }else if(pathname === `/users/${username}/statistics`){ @@ -226,7 +227,7 @@ class Infos extends Component {