forked from Gitlink/forgeplus-react
修改user/org路由时的bug
This commit is contained in:
parent
0b64631222
commit
662a758980
16
src/App.js
16
src/App.js
|
@ -101,6 +101,7 @@ class App extends Component {
|
||||||
occupation: 0,
|
occupation: 0,
|
||||||
mygetHelmetapi: null,
|
mygetHelmetapi: null,
|
||||||
pathType: null,
|
pathType: null,
|
||||||
|
pathName:'',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,29 +110,30 @@ class App extends Component {
|
||||||
let pathname = window.location.pathname ? window.location.pathname.split('/')[1] : '';
|
let pathname = window.location.pathname ? window.location.pathname.split('/')[1] : '';
|
||||||
pathname && this.getPathnameType(pathname);
|
pathname && this.getPathnameType(pathname);
|
||||||
|
|
||||||
this.unlisten = this.props.history.listen((location,action) => {
|
// 添加路由监听,决定组织还是个人
|
||||||
// 最新路由的 location 对象,可以通过比较 pathname 是否相同来判断路由的变化情况
|
this.unlisten = this.props.history.listen((location) => {
|
||||||
let newPathname = location.pathname.split('/')[1];
|
let newPathname = location.pathname.split('/')[1];
|
||||||
|
if(this.state.pathName!==newPathname){
|
||||||
newPathname && this.getPathnameType(newPathname);
|
newPathname && this.getPathnameType(newPathname);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getPathnameType = (pathname) => {
|
getPathnameType = (pathname) => {
|
||||||
let keyWord = ["Gitlink", "Trustie", "explore", "settings", "setting", "CCF", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email",];
|
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')) {
|
if (!keyWord.includes(pathname)) {
|
||||||
let url = `/owners/${pathname}.json`;
|
let url = `/owners/${pathname}.json`;
|
||||||
axios.get(url).then((response) => {
|
axios.get(url).then((response) => {
|
||||||
if (response && response.status === 200) {
|
if (response && response.status === 200) {
|
||||||
this.setState({
|
this.setState({
|
||||||
pathType: response.data.type || '404'
|
pathType: response.data.type || '404',
|
||||||
|
pathName:pathname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HideAddcoursestypess = (i) => {
|
HideAddcoursestypess = (i) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
Addcoursestype: false,
|
Addcoursestype: false,
|
||||||
|
|
|
@ -11,9 +11,9 @@ broadcastChannelOnmessage('refreshPage', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
function locationurl(list) {
|
function locationurl(list) {
|
||||||
if (window.location.port !== "3007") {
|
// if (window.location.port !== "3007") {
|
||||||
window.location.href = list
|
window.location.href = list
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
// TODO 开发期多个身份切换
|
// TODO 开发期多个身份切换
|
||||||
let debugType = ""
|
let debugType = ""
|
||||||
|
@ -85,8 +85,11 @@ export function initAxiosInterceptors(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.data.status === 404) {
|
if (response.data.status === 404) {
|
||||||
|
let responseURL = response.data.request.responseURL;
|
||||||
|
if (responseURL.indexOf('/api/users/') === -1 && responseURL.indexOf('/api/organizations/') === -1) {
|
||||||
locationurl('/nopage');
|
locationurl('/nopage');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (response.data.status === 500) {
|
if (response.data.status === 500) {
|
||||||
locationurl('/500');
|
locationurl('/500');
|
||||||
|
|
|
@ -56,10 +56,6 @@ export default Form.create()(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(){
|
|
||||||
history.push(`/test2org`);
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
setFieldsValue({
|
setFieldsValue({
|
||||||
visibility:"common"
|
visibility:"common"
|
||||||
|
@ -149,7 +145,7 @@ export default Form.create()(
|
||||||
<p className="mt20">
|
<p className="mt20">
|
||||||
<Button type="primary" className="mr30" onClick={createOrganize}>创建组织</Button>
|
<Button type="primary" className="mr30" onClick={createOrganize}>创建组织</Button>
|
||||||
<Button className="grey" onClick={()=>{window.history.back(-1)}}>取消</Button>
|
<Button className="grey" onClick={()=>{window.history.back(-1)}}>取消</Button>
|
||||||
<Button className="grey" onClick={test}>test</Button>
|
<Button className="grey" onClick={()=>{test}}>test</Button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -77,7 +77,7 @@ function Detail(props){
|
||||||
{
|
{
|
||||||
detail &&
|
detail &&
|
||||||
<Cards
|
<Cards
|
||||||
src={`/organize/${detail.name}`}
|
src={`/${detail.name}`}
|
||||||
title={detail.nickname}
|
title={detail.nickname}
|
||||||
desc={!buttonflag && detail.description}
|
desc={!buttonflag && detail.description}
|
||||||
img={detail.avatar_url}
|
img={detail.avatar_url}
|
||||||
|
|
Loading…
Reference in New Issue