diff --git a/src/App.js b/src/App.js index d03337319..ea760e075 100644 --- a/src/App.js +++ b/src/App.js @@ -101,6 +101,7 @@ class App extends Component { occupation: 0, mygetHelmetapi: null, pathType: null, + pathName:'', } } @@ -109,29 +110,30 @@ class App extends Component { let pathname = window.location.pathname ? window.location.pathname.split('/')[1] : ''; pathname && this.getPathnameType(pathname); - this.unlisten = this.props.history.listen((location,action) => { - // 最新路由的 location 对象,可以通过比较 pathname 是否相同来判断路由的变化情况 - let newPathname = location.pathname.split('/')[1]; - newPathname&&this.getPathnameType(newPathname); + // 添加路由监听,决定组织还是个人 + this.unlisten = this.props.history.listen((location) => { + let newPathname = location.pathname.split('/')[1]; + if(this.state.pathName!==newPathname){ + newPathname && this.getPathnameType(newPathname); + } }); } 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 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"]; + 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' + pathType: response.data.type || '404', + pathName:pathname, }) } }); } } - - HideAddcoursestypess = (i) => { this.setState({ Addcoursestype: false, @@ -155,7 +157,7 @@ class App extends Component { const msg = `${event.type}: ${event.message}`; }); - + } componentWillUnmount() { diff --git a/src/AppConfig.js b/src/AppConfig.js index 034612ece..c6cbac502 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -11,9 +11,9 @@ broadcastChannelOnmessage('refreshPage', () => { }) function locationurl(list) { - if (window.location.port !== "3007") { + // if (window.location.port !== "3007") { window.location.href = list - } + // } } // TODO 开发期多个身份切换 let debugType = "" @@ -85,7 +85,10 @@ export function initAxiosInterceptors(props) { } if (response.data.status === 404) { - locationurl('/nopage'); + let responseURL = response.data.request.responseURL; + if (responseURL.indexOf('/api/users/') === -1 && responseURL.indexOf('/api/organizations/') === -1) { + locationurl('/nopage'); + } } if (response.data.status === 500) { diff --git a/src/forge/Team/New.jsx b/src/forge/Team/New.jsx index 34cda6b76..b39711338 100644 --- a/src/forge/Team/New.jsx +++ b/src/forge/Team/New.jsx @@ -56,10 +56,6 @@ export default Form.create()( }) } - function test(){ - history.push(`/test2org`); - } - useEffect(()=>{ setFieldsValue({ visibility:"common" @@ -149,7 +145,7 @@ export default Form.create()(

- +

) diff --git a/src/forge/Team/Sub/Detail.jsx b/src/forge/Team/Sub/Detail.jsx index 36d8a9160..6919d3d5e 100644 --- a/src/forge/Team/Sub/Detail.jsx +++ b/src/forge/Team/Sub/Detail.jsx @@ -77,7 +77,7 @@ function Detail(props){ { detail &&