diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 0ed2882a7..15632227d 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -110,9 +110,81 @@ export function initAxiosInterceptors(props) { let proxy = "https://test-newweb.educoder.net" - // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; - // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 - const requestMap = {}; + axios.interceptors.request.use( + config => { + // config.headers['Content-Type']= 'no-cache' + // if (token) { // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 + // config.headers.Authorization = token; + // } + + // --------------------------------------------- 測試3007连测试服的代码 + // if (url.indexOf('file_update') != -1 || url.indexOf('game_build') != -1 || url.indexOf('game_status') != -1) { + // proxy = 'https://testbdweb.trustie.net' + // } else { + // proxy = 'http://localhost:3000' + // } + // --------------------------------------------- + if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) { + return config + } + requestProxy(config) + + let url = `/api${config.url}`; + + //qq登录去掉api + if (config.params && config.params.redirect_uri != undefined) { + if (config.params.redirect_uri.indexOf('otherloginqq') != -1) { + url = `${config.url}`; + } + } + if (`${config[0]}` != `true`) { + let timestamp = Date.parse(new Date()) / 1000; + if (window.location.port === "3007") { + // let timestamp=railsgettimes(proxy); + // console.log(timestamp) + railsgettimes(`${proxy}/api/main/first_stamp.json`); + let newopens = md5(opens + timestamp) + config.url = `${proxy}${url}`; + if (config.url.indexOf('?') == -1) { + config.url = `${config.url}?debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`; + } else { + config.url = `${config.url}&debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`; + } + } else { + // 加api前缀 + railsgettimes(`/api/main/first_stamp.json`); + let newopens = md5(opens + timestamp) + config.url = url; + if (config.url.indexOf('?') == -1) { + config.url = `${config.url}?randomcode=${timestamp}&client_key=${newopens}`; + } else { + config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`; + } + } + } + // + // console.log(config); + // if (config.method === "post") { + // if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止 显示这个方法会影响到定制信息 + // // console.log(config); + // // console.log(JSON.parse(config)); + // // console.log(config.url); + // // console.log("被阻止了是重复请求================================="); + // return false; + // } + // } + // 非file_update请求 + if (config.url.indexOf('update_file') === -1) { + requestMap[config.url] = true; + + window.setTimeout("setfalseInRequestMap('" + config.url + "')", 900) + } + // setTimeout("setfalseInRequestMap(" + config.url + ")", 1200) + return config; + }, + err => { + return Promise.reject(err); + }); window.setfalseInRequestMap = function (keyName) { requestMap[keyName] = false; diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index ac938e2f2..3c4a5cabf 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -20,6 +20,8 @@ import TPMShixunDiscussContainer from './TPMShixunDiscussContainer'; import TPMRepositoryComponent from './TPMRepositoryComponent'; +import TPMRepositoryComponentdetails from './TPMRepositoryComponentdetails'; + import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; import TPMsettings from './TPMsettings/TPMsettings'; @@ -132,6 +134,11 @@ const AddFile = Loadable({ loader: () => import('./shixunchild/Repository/RepositoryAddFile'), loading: Loading, }) +// 版本库上传文件 +const Uploadfile = Loadable({ + loader: () => import('./shixunchild/Repository/RepositoryAddFileupload_file'), + loading: Loading, +}) const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.json' , 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json'] @@ -235,36 +242,25 @@ class TPMIndex extends Component { public: response.data.public, is_jupyter: response.data.is_jupyter === undefined || response.data.is_jupyter === null ? false : response.data.is_jupyter, }); - - if (userid) { - if (response.data.identity < 4) { - if (newTPMsettings === undefined || newTPMsettings === false || newTPMsettings === null) { - console.log() - this.setState({ - openknows: true - }) - } else { - this.setState({ - openknows: false - }) - } - } - } - - } - }).catch((error) => { - this.setState({ - shixunsDetails: undefined, - shixunId: undefined, - star_info: undefined, - star_infos: undefined, - power: undefined, - identity: undefined, - status: undefined, - propaedeutics: undefined, - is_jupyter: false, }); - }); + + // this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => { + // let url = config.url; + // // console.log('tpmContentRequestInterceptor:', url) + // for ( let i = 0; i < interceptorUrlArray.length; i++ ) { + // if (url.indexOf(interceptorUrlArray[i]) != -1) { + // url = url.split('?')[0] + // console.log('loadingContent, url:', url) + // + // this.setState({ loadingContent: true }) + // + // cacheInterceptorUrlMap[url] = true + // } + // } + // return config; + // }, function (error) { + // return Promise.reject(error); + // }); this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => { let url = config.url; @@ -386,7 +382,8 @@ class TPMIndex extends Component { render() { let url = window.location.href; - let flag = url.indexOf("add_file") > -1; + let flag = false; + // url.indexOf("add_file")>-1; return (
*/}
+ {/*