diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index fda5e7918..f5279573b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -100,6 +100,31 @@ export function initAxiosInterceptors(props) { // proxy="https://test-newweb.educoder.net" // proxy="https://test-jupyterweb.educoder.net" //proxy="http://192.168.2.63:3001" + 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]; + _search.split('&').forEach(item => { + const _arr = item.split('='); + if(_arr[0]==='_educoder_session'){ + cookie.save('_educoder_session',_arr[1],{ path: '/' }); + cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'}); + + }else{ + cookie.save('autologin_trustie',_arr[1],{ path: '/' }); + cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'}); + } + }); + } + } + }catch (e) { + + } // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 @@ -127,7 +152,53 @@ export function initAxiosInterceptors(props) { // console.log("开始请求了"); // console.log(config.url); // console.log(window.location.pathname); + // + + // 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 } diff --git a/public/react/src/modules/wxcode/index.js b/public/react/src/modules/wxcode/index.js index 37c2ef176..7e5c9362b 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -46,22 +46,22 @@ const App = (props) => { // 获取路径参数 const setCookier = () => { - const _params = window.location.search; - if (_params) { - let _search = _params.split('?')[1]; - _search.split('&').forEach(item => { - // console.log(item); - const _arr = item.split('='); - cookie.remove(_arr[0], { - path: '/', - domain: '.educoder.net' - }); - cookie.save(_arr[0], _arr[1], { - path: '/', - domain: '.educoder.net' - }); - }); - } + // const _params = window.location.search; + // if (_params) { + // let _search = _params.split('?')[1]; + // _search.split('&').forEach(item => { + // // console.log(item); + // const _arr = item.split('='); + // cookie.remove(_arr[0], { + // path: '/', + // domain: '.educoder.net' + // }); + // cookie.save(_arr[0], _arr[1], { + // path: '/', + // domain: '.educoder.net' + // }); + // }); + // } } setCookier(); const [isActive, setIsActive] = useState(-1); @@ -156,7 +156,7 @@ const App = (props) => { changeWXCodeEvaluateDialog(false); loadResult(next_game); } - + const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case'; const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading'; const dialog = showDialog ? 'pass-dialog active' : 'pass-dialog'; @@ -287,7 +287,7 @@ const App = (props) => { 经验值 <span className="value_color">{experience > 0 ? `+${experience}` : 0}</span> </p> { - next_game + next_game ? ( <div className="pass-btn"> <button className="btn btn-first" onClick={handleClickShowResult}>评测结果</button> diff --git a/public/react/src/services/wxcodeService.js b/public/react/src/services/wxcodeService.js index e00141c3f..1d8acd4e3 100644 --- a/public/react/src/services/wxcodeService.js +++ b/public/react/src/services/wxcodeService.js @@ -11,19 +11,19 @@ import cookie from 'react-cookies' // axios.defaults.withCredentials = true; const setCookier = () => { - const _params = window.location.search; - if (_params) { - let _search = _params.split('?')[1]; - _search.split('&').forEach(item => { - // console.log(item); - const _arr = item.split('='); - cookie.remove(_arr[0], { - path: '/', - domain: '.educoder.net' - }); - cookie.save(_arr[0], _arr[1], { domain: '.educoder.net', path: '/'}); - }); - } + // const _params = window.location.search; + // if (_params) { + // let _search = _params.split('?')[1]; + // _search.split('&').forEach(item => { + // // console.log(item); + // const _arr = item.split('='); + // cookie.remove(_arr[0], { + // path: '/', + // domain: '.educoder.net' + // }); + // cookie.save(_arr[0], _arr[1], { domain: '.educoder.net', path: '/'}); + // }); + // } } // 获取代码块