From 476db75f59a0f628509af20b1caf3cf996bd221d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 17 Jan 2020 21:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 23 ----------------- public/react/src/modules/wxcode/index.js | 29 ++++++++++------------ public/react/src/services/wxcodeService.js | 29 ++++++++++------------ 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 72053896b..fda5e7918 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -127,29 +127,6 @@ 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]; - _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 67bea0524..f603cf36a 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -41,22 +41,19 @@ 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], { domain: '.educoder.net', path: '/'}); + }); + } } setCookier(); const [isActive, setIsActive] = useState(-1); diff --git a/public/react/src/services/wxcodeService.js b/public/react/src/services/wxcodeService.js index c03514155..a2332f89b 100644 --- a/public/react/src/services/wxcodeService.js +++ b/public/react/src/services/wxcodeService.js @@ -11,22 +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], { - // 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], { domain: '.educoder.net', path: '/'}); + }); + } } // 获取代码块