diff --git a/src/AppConfig.js b/src/AppConfig.js
index 8212b42e3..337d0120d 100644
--- a/src/AppConfig.js
+++ b/src/AppConfig.js
@@ -65,7 +65,7 @@ export function initAxiosInterceptors(props) {
});
axios.interceptors.response.use(function (response) {
- if (response === undefined) {
+ if (response === undefined || !response.data) {
return
}
const config = response.config;
diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js
index 5d65547ab..42322cfdb 100644
--- a/src/forge/Main/Detail.js
+++ b/src/forge/Main/Detail.js
@@ -10,6 +10,9 @@ import cookie from 'react-cookies';
import { setSeoMeta } from 'educoder';
import { Base64 } from 'js-base64';
import { setProject, setProjectDetail, setProjectEntries, setProjectMenuList, setProjectReadMe } from '../../redux/actions/server';
+import actions from '../../redux/actions';
+import types from '../../redux/actions/actionTypes'
+import { getProjectFunc, getProjectDetailFunc } from '../../services/project'
import '../css/index.scss'
import './list.scss';
@@ -168,21 +171,6 @@ function checkPathname(projectsId, owner, pathname) {
return name;
}
-const getProjectFunc = (owner, projectsId, isServer = false) => {
- const url = isServer ? `https://www.gitlink.org.cn/api/${owner}/${projectsId}/simple.json` : `/${owner}/${projectsId}/simple.json`;
- return axios.get(url)
-}
-
-const getDetailFunc = (owner, projectsId, isServer = false) => {
- const url = isServer ? `https://www.gitlink.org.cn/api/${owner}/${projectsId}/detail.json` : `/${owner}/${projectsId}/detail.json`;
- return axios.get(url)
-}
-
-const getBannerFunc = (owner, projectsId, isServer = false) => {
- const url = isServer ? `https://www.gitlink.org.cn/api/${owner}/${projectsId}/menu_list.json` : `/${owner}/${projectsId}/menu_list.json`;
- return axios.get(url)
-}
-
class Detail extends Component {
constructor(props) {
super(props);
@@ -220,6 +208,12 @@ class Detail extends Component {
// this.getProject();
let history = this.props.location;
this.clearIssueCookies(history);
+ if (this.props.clearProject) {
+ const typeList = [ types.GET_PROJECT_BASE, types.GET_PROJECT_DETAIL, types.GET_PROJECT_ENTRIES, types.GET_PROJECT_MENU, types.GET_PROJECT_README ]
+ typeList.forEach(e => {
+ this.props.clearProject(e)
+ })
+ }
}
componentDidUpdate = async (prevState) => {
@@ -307,7 +301,7 @@ class Detail extends Component {
if (this.props.defaultDetail) {
projectdata = this.props.defaultDetail
} else {
- projectdata = await getDetailFunc(owner, projectsId, !window.location.host).data;
+ projectdata = await getProjectDetailFunc(owner, projectsId, !window.location.host).data;
}
if (projectdata) {
this.getDetail(projectdata)
@@ -939,6 +933,10 @@ const mapStateToProps = (state) => {
};
}
+const mapDispatchToProps = (dispatch) => ({
+ clearProject: (type) => dispatch(actions.clearProject(type)),
+});
+
Detail.preFetch = ({ store, match, query }) => {
return new Promise(async function(resolve, reject) {
let { dispatch, getState } = store;
@@ -950,7 +948,6 @@ Detail.preFetch = ({ store, match, query }) => {
dispatch(setProjectEntries({...match.params, branch: 'master'})),
dispatch(setProjectMenuList(match.params)),
dispatch(setProjectReadMe({...match.params, branch: 'master'}))
-
];
const data = await Promise.all(promises);
resolve({
@@ -960,5 +957,6 @@ Detail.preFetch = ({ store, match, query }) => {
};
export default withRouter(connect(
- mapStateToProps
+ mapStateToProps,
+ mapDispatchToProps
)(Detail));
\ No newline at end of file
diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js
index 2d037f694..383049656 100644
--- a/src/forge/Main/IndexItem.js
+++ b/src/forge/Main/IndexItem.js
@@ -28,16 +28,16 @@ class IndexItem extends Component {
:
- { window.location.href = `/${i.author && i.author.login}/${i.identifier}` }} className="show-user-link">
+ { window.location.href = `/${item.author && item.author.login}/${item.identifier}` }} className="show-user-link">
}
{i.description}
{/* 项目标签 */} {i.topics &&