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"> }
- + { window.location.href = `/${item.author && item.author.login}/${item.identifier}` }} title={`${item.author.name}/${item.name}`} className="color-grey-3 font-18 task-hide " style={{maxWidth: 470 }}> {item.author.name}/{item.name} - + { !item.is_public && 私有 } { item.forked_from_project_id ? diff --git a/src/forge/users/GeneralView/ConcentrateProject.jsx b/src/forge/users/GeneralView/ConcentrateProject.jsx index 9affebca3..36fe2f331 100644 --- a/src/forge/users/GeneralView/ConcentrateProject.jsx +++ b/src/forge/users/GeneralView/ConcentrateProject.jsx @@ -87,7 +87,7 @@ function ConcentrateProject({ list.map((i,k)=>{ return(
  • - {i.name} + { window.location.href = `/${i.author && i.author.login}/${i.identifier}`}}className="name task-hide">{i.name}

    {i.description}

    {/* 项目标签 */} {i.topics &&
    diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js index f29b63f0b..d7135382e 100644 --- a/src/modules/tpm/TPMIndexHOC.js +++ b/src/modules/tpm/TPMIndexHOC.js @@ -294,7 +294,6 @@ export function TPMIndexHOC(WrappedComponent) { }; let path =this.props.location.pathname; let pathCheck = path.indexOf("/zone")>-1 && path.indexOf("/newdetail")>-1 && IsPC(); - console.log('+++++++++++++++++++++++++++++++fdsafgsda++++++++++++++') return (
    { } } +export const clearProject = (type) => { + return { + type: type, + payload: '' + } +} + // 获取项目详情信息 export const setProjectDetail = ({ owner,projectsId }) => { return (dispatch) => { @@ -58,11 +65,13 @@ export const setProjectMenuList = ({ owner,projectsId }) => { export const setProjectReadMe = ({ owner,projectsId, branch }) => { return (dispatch) => { return getProjectReadMe(owner, projectsId, branch).then(res => { - dispatch({ - type: types.GET_PROJECT_README, - payload: res.data - }); - return res.data + if (res && res.data) { + dispatch({ + type: types.GET_PROJECT_README, + payload: res.data + }); + return res.data + } }) } }