dev_tj
杨树林 5 years ago
parent d05c274813
commit b7cb687ec3

@ -38,14 +38,6 @@ function setCookier(){
}
}
function setCookie(key, value) {
const d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
const expires = "expires=" + d.toGMTString();
document.cookie = `_educoder_session=${key}; domain=.educoder.net; path=/; expires=${expires}`;
}
// TODO 开发期多个身份切换
let debugType =""
if (isDev) {
@ -108,30 +100,34 @@ 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) {
//
// }
try {
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
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: '/' });
}
});
}
}
}
}catch (e) {
}
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制
@ -203,37 +199,7 @@ export function initAxiosInterceptors(props) {
// }catch (e) {
//
// }
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],{ path: '/' });
cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'});
_educoder_sessionmys=_arr[1];
}else{
cookie.save('autologin_trustie',_arr[1],{ path: '/' });
cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'});
autologin_trusties=_arr[1];
}
});
config.headers["Cookie"] = `_educoder_session=${_educoder_sessionmys}; autologin_trustie=${autologin_trusties} `;
config.headers.Authorization = `_educoder_session=${_educoder_sessionmys}; autologin_trustie=${autologin_trusties} `;
config.headers.Cookie =`_educoder_session=${_educoder_sessionmys}; autologin_trustie=${autologin_trusties} `;
}
}
}catch (e) {
}
if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) {

@ -46,26 +46,26 @@ const App = (props) => {
// 获取路径参数
const _params = window.location.search;
const setCookier = () => {
// var u = navigator.userAgent;
// var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// if (isIOS) {
// }else{
// if (_params) {
// let _cookie = '';
// let _search = _params.split('?')[1];
// if(_search.split('=')) {
// _cookie = _search.split('=')[1];
// cookie.save('_educoder_session', _cookie);
// }
// _search.split('&').forEach(item => {
// const _arr = item.split('=');
// cookie.save(_arr[0], _arr[1], {
// path: '/',
// domain: '.educoder.net'
// });
// });
// }
// }
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
}else{
if (_params) {
let _cookie = '';
let _search = _params.split('?')[1];
// if(_search.split('=')) {
// _cookie = _search.split('=')[1];
// cookie.save('_educoder_session', _cookie);
// }
_search.split('&').forEach(item => {
const _arr = item.split('=');
cookie.save(_arr[0], _arr[1], {
path: '/',
domain: '.educoder.net'
});
});
}
}
}
setCookier();
@ -247,12 +247,12 @@ const App = (props) => {
测试集{i + 1}
</h2>
{
is_public
is_public
? compile_success > 0
? result ? <span className="iconfont icon-wancheng case_item_success"></span>
: <span className="iconfont icon-jinggao1 case_item_fail"></span>
: ''
:
:
<span className="case-item-tips">隐藏测试集暂不支持解锁和查看 </span>
// is_public
// ? result ? <span className="iconfont icon-wancheng case_item_success"></span>

Loading…
Cancel
Save