diff --git a/src/AppConfig.js b/src/AppConfig.js index 5e9c21fda..27222e31a 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -30,7 +30,7 @@ function locationurl(list){ // TODO 开发期多个身份切换 - let debugType ="" +let debugType ="" if (isDev) { const _search = window.location.search; let parsed = {}; @@ -49,9 +49,6 @@ if (isDev) { //debugType="student"; - - - function clearAllCookie() { cookie.remove('_educoder_session', {path: '/'}); cookie.remove('autologin_trustie', {path: '/'}); @@ -114,26 +111,12 @@ setpostcookie(); } - - - - window._debugType = debugType; export function initAxiosInterceptors(props) { initOnlineOfflineListener() - // TODO 避免重复的请求 https://github.com/axios/axios#cancellation - // https://github.com/axios/axios/issues/1497 - - // TODO 读取到package.json中的配置? - - - var //proxy = "http://localhost:3000" - proxy="https://testforgeplus.trustie.net/" - // proxy="http://localhost:3000" - - // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; - // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 + var //proxy = "http://localhost:3000" + proxy="https://testforgeplus.trustie.net/" const requestMap = {}; window.setfalseInRequestMap = function(keyName) { @@ -143,242 +126,110 @@ export function initAxiosInterceptors(props) { //响应前的设置 axios.interceptors.request.use( config => { - setpostcookie() - clearAllCookie() - // config.headers['Content-Type']= 'no-cache' - // if (token) { // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 - // config.headers.Authorization = token; - // } + setpostcookie() + clearAllCookie() + if (config.url.indexOf(proxy) !== -1 || config.url.indexOf(':') !== -1) { + return config + } + requestProxy(config) - // --------------------------------------------- 測試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' - // } - // --------------------------------------------- - // console.log("开始请求了"); - // console.log(config.url); - // console.log(window.location.pathname); - // + let url = `/api${config.url}`; - // try { - // const str =window.location.pathname; - // if(str.indexOf("/wxcode") !== -1){ - // // console.log("开始重写cookis"); - // const _params = window.location.search; - // // console.log("1111"); - // if (_params) { - // // console.log("22222"); - // let _search = _params.split('?')[1]; - // var _educoder_sessionmys=""; - // var autologin_trusties=""; - // _search.split('&').forEach(item => { - // const _arr = item.split('='); - // if(_arr[0]==='_educoder_session'){ - // cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'}); - // _educoder_sessionmys=_arr[1]; - // }else{ - // cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'}); - // autologin_trusties=_arr[1]; - // } - // }); - // try { - // const autlogins= `_educoder_session=${_educoder_sessionmys}; autologin_trustie=${autologin_trusties} `; - // config.params = {'Cookie': autlogins} - // config.headers['Cookie'] =autlogins; - // // console.log("设置了cookis"); - // } catch (e) { - // - // } - // try { - // const autloginysls= `_educoder_session=${_educoder_sessionmys}; autologin_trustie=${autologin_trusties} `; - // config.params = {'autloginysls': autloginysls} - // config.headers['Cookie'] =autloginysls; - // // console.log("设置了cookis"); - // }catch (e) { - // - // } - // } - // } - // }catch (e) { - // - // } - - - - if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) { - return config + //qq登录去掉api + if(config.params&&config.params.redirect_uri!=undefined){ + if(config.params.redirect_uri.indexOf('otherloginqq')!=-1){ + url = `${config.url}`; } - 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) - // `https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp` - // 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}`; - } else { - config.url = `${config.url}&debug=${debugType}`; - } + } + if(`${config[0]}`!=`true`){ + let timestamp = Date.parse(new Date())/1000; + if (window.location.port === "3007") { + config.url = `${proxy}${url}`; + if (config.url.indexOf('?') == -1) { + config.url = `${config.url}?debug=${debugType}`; } else { - // 加api前缀 - // railsgettimes(`http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`); - - // 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}`; - // } + config.url = `${config.url}&debug=${debugType}`; } - setpostcookie(); - } - // - // console.log(config); + } else { + // 加api前缀 + config.url = url; + } + setpostcookie(); + } 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; + // 非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; + window.setTimeout("setfalseInRequestMap('"+config.url+"')", 900) + } + // setTimeout("setfalseInRequestMap(" + config.url + ")", 1200) + return config; }, err => { return Promise.reject(err); }); axios.interceptors.response.use(function (response) { - - // console.log(".............") if(response===undefined){ return } const config = response.config if (response.data.status === -1) { - // console.error('error:', response.data.message) - // throw new Error() - - // https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=cancel+request+in+response+interceptors+ - // https://github.com/axios/axios/issues/583 - // message.info(response.data.message || '服务端返回status -1,请联系管理员。'); - // props.showSnackbar( response.data.message || '服务器异常,请联系管理员。' ) - if (window.location.pathname.startsWith('/tasks/')) { - props.showSnackbar( response.data.message || '服务器异常,请联系管理员。' ) - } else { - notification.open({ - message:"提示", - description: response.data.message || '服务器异常,请联系管理员。', - style: { - zIndex: 99999999 - }, - }); - // notification['error']({ - // message:"提示", - // description: response.data.message || '服务器异常,请联系管理员。', - // }); - } - - throw new axios.Cancel('Operation canceled by the user.'); + if (window.location.pathname.startsWith('/tasks/')) { + props.showSnackbar( response.data.message || '服务器异常,请联系管理员。' ) } else { - // hash跳转 - // var hash = window.location.hash; - // if (hash) { - // hashTimeout && window.clearTimeout(hashTimeout) - // hashTimeout = setTimeout(() => { - // var element = document.querySelector(hash); - // if (element) { - // element.scrollIntoView(); - // } - // }, 400) - // } - } - // if(response.data.status === 401){ - // console.log("401401401") - // } - if (response.data.status === 403||response.data.status === "403") { - locationurl('/403'); - } - - if (response.data.status === 404) { - locationurl('/nopage'); - } - - if (response.data.status === 500) { - locationurl('/500'); - } - - if (response.data.status === 501) { - if(message501===false){ - message501=true notification.open({ - message:"提示", - description:response.data.message || '访问异常,请求不合理', - style: { + message:"提示", + description: response.data.message || '服务器异常,请联系管理员。', + style: { zIndex: 99999999 - } - }) - } - window.setTimeout(function () { - message501=false - }, 2000); + }, + }); + // notification['error']({ + // message:"提示", + // description: response.data.message || '服务器异常,请联系管理员。', + // }); } + throw new axios.Cancel('Operation canceled by the user.'); + } + if (response.data.status === 403||response.data.status === "403") { + locationurl('/403'); + } - // if (response.data.status === 402) { - // console.log(response.data.status); - // console.log(response.data); - // // locationurl(402); - // } + if (response.data.status === 404) { + locationurl('/nopage'); + } - // - // if (response.data.status === 401) { - // console.log("161"); - // console.log(config); - // return config; - // } - // if (response.data.status === 407) { - // 在app js 中解决 Trialapplication - // // - // ///在appjs - // notification.open({ - // message:"提示", - // description: "账号未认证", - // }); - // throw new axios.Cancel('Operation canceled by the user.'); - // // - // } + if (response.data.status === 500) { + locationurl('/500'); + } - requestMap[response.config.url] = false; - setpostcookie(); - return response; + if (response.data.status === 501) { + if(message501===false){ + message501=true + notification.open({ + message:"提示", + description:response.data.message || '访问异常,请求不合理', + style: { + zIndex: 99999999 + } + }) + } + window.setTimeout(function () { + message501=false + }, 2000); + } + requestMap[response.config.url] = false; + setpostcookie(); + return response; }, function (error) { - return Promise.reject(error); + return Promise.reject(error); }); // ----------------------------------------------------------------------------------- diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 4c5f1a2a6..435f64b07 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -22,6 +22,7 @@ import img_fork from "../Images/fork.png"; * subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮) * readMeContent:根目录下面的readme文件内容 */ + class CoderRootDirectory extends Component{ constructor(props){ super(props); @@ -294,8 +295,6 @@ class CoderRootDirectory extends Component{ :"" } - - {/*{truncateCommitId(branchLastCommit.last_commit.id)}*/} {branchLastCommit.last_commit.message} {truncateCommitId(branchLastCommit.last_commit.id)} {branchLastCommit.last_commit.time_from_now} diff --git a/src/modules/tpm/NewHeader.js b/src/modules/tpm/NewHeader.js index c0e6ee285..09ca7af07 100644 --- a/src/modules/tpm/NewHeader.js +++ b/src/modules/tpm/NewHeader.js @@ -886,9 +886,6 @@ submittojoinclass=(value)=>{ if(mygetHelmetapi2) { if (mygetHelmetapi2.navbar) { if (mygetHelmetapi2.navbar.length > 0) { - // console.log("mygetHelmetapi2.navbar.length>0====-=-=--=-=-=-="); - // - // console.log(match.path); if (match.path === '/') { if (headtypesonClickbool === false) { headtypes = undefined; @@ -907,10 +904,6 @@ submittojoinclass=(value)=>{ } } } - - // console.log(mygetHelmetapi2); - // console.log("NewHeadermygetHelmetapi123123123123"); - let shixuntype=false; let pathstype=false; let coursestypes=false; @@ -1008,22 +1001,8 @@ submittojoinclass=(value)=>{ mygetHelmetapi2!==undefined&&mygetHelmetapi2.navbar!==null&&mygetHelmetapi2.navbar!==undefined&&mygetHelmetapi2.navbar.length>0?
: - {/*
*/}
请输入6位项目邀请码
*/} - - {/*请选择一个身份
*/} - - {/*