diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index cf813573c..72053896b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -5,6 +5,7 @@ import md5 from 'md5'; import { requestProxy } from "./indexEduplus2RequestProxy"; import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder'; import { notification } from 'antd'; +import cookie from 'react-cookies'; import './index.css'; const $ = window.$; const opens ="79e33abd4b6588941ab7622aed1e67e8"; @@ -24,6 +25,18 @@ function locationurl(list){ } +function 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.save('_educoder_session',_arr[0]); + cookie.save('autologin_trustie',_arr[1]); + }); + } +} // TODO 开发期多个身份切换 let debugType ="" @@ -96,7 +109,7 @@ export function initAxiosInterceptors(props) { requestMap[keyName] = false; } - + //响应前的设置 axios.interceptors.request.use( config => { // config.headers['Content-Type']= 'no-cache' @@ -111,6 +124,33 @@ export function initAxiosInterceptors(props) { // proxy = 'http://localhost:3000' // } // --------------------------------------------- + // 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]; + _search.split('&').forEach(item => { + const _arr = item.split('='); + if(_arr[0]==='_educoder_session'){ + cookie.save('_educoder_session',_arr[1],{ path: '/' }); + }else{ + cookie.save('autologin_trustie',_arr[1],{ path: '/' }); + } + }); + } + } + }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 2fb871288..67bea0524 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -1,7 +1,7 @@ /* * @Description: 微信端代码编辑器 * @Author: tangjiang - * @Github: + * @Github: * @Date: 2020-01-15 09:56:34 * @LastEditors : tangjiang * @LastEditTime : 2020-01-17 15:34:40 @@ -35,28 +35,28 @@ const App = (props) => { evaluateWxCode, showWXCodeTextCase, changeWXCodeEvaluateLoading - } = props; + } = props; const {identifier} = props.match.params; // 获取路径参数 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); @@ -111,7 +111,7 @@ const App = (props) => { updateWXCodeForInterval(identifier, path); }, 10000); } - } + } // 关闭单个测试集 const handleCloseItem = (i, flag) => { @@ -130,7 +130,7 @@ const App = (props) => { changeWXCodeEvaluateLoading(true); evaluateWxCode(identifier, path); } - + const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case'; const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading'; const _val = sets_error_count === 0; @@ -200,19 +200,19 @@ const App = (props) => { { is_public - ? (result + ? (result ? : ) : ( 隐藏测试集,暂不支持解锁和查看 - {/* {result + {/* {result ? : } */} ) } - +
测试输入 {input || '-'} diff --git a/public/react/src/services/wxcodeService.js b/public/react/src/services/wxcodeService.js index 073f248fa..c03514155 100644 --- a/public/react/src/services/wxcodeService.js +++ b/public/react/src/services/wxcodeService.js @@ -1,7 +1,7 @@ /* - * @Description: + * @Description: * @Author: tangjiang - * @Github: + * @Github: * @Date: 2020-01-15 15:44:36 * @LastEditors : tangjiang * @LastEditTime : 2020-01-17 16:40:03 @@ -11,27 +11,27 @@ 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], { - 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' + // }); + // }); + // } } // 获取代码块 export async function fetchWxCode (identifier, params) { - setCookier(); + setCookier(); const url = `/tasks/${identifier}/rep_content.json`; params = Object.assign({}, params, {withCredentials: true}); return axios.get(url, {params});