|
|
|
@ -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) {
|
|
|
|
|