|
|
|
@ -201,6 +201,8 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
//响应前的设置
|
|
|
|
|
axios.interceptors.request.use(
|
|
|
|
|
config => {
|
|
|
|
|
setpostcookie()
|
|
|
|
|
clearAllCookie()
|
|
|
|
|
// config.headers['Content-Type']= 'no-cache'
|
|
|
|
|
// if (token) { // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了
|
|
|
|
|
// config.headers.Authorization = token;
|
|
|
|
@ -263,6 +265,114 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) {
|
|
|
|
|
return config
|
|
|
|
|
}
|
|
|
|
|
requestProxy(config)
|
|
|
|
|
|
|
|
|
|
let url = `/api${config.url}`;
|
|
|
|
|
|
|
|
|
|
//qq登录去掉api
|
|
|
|
|
if(config.params&&config.params.redirect_uri!=undefined){
|
|
|
|
|
if(config.params.redirect_uri.indexOf('otherloginqq')!=-1){
|
|
|
|
|
url = `${config.url}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(`${config[0]}`!=`true`){
|
|
|
|
|
let timestamp = Date.parse(new Date())/1000;
|
|
|
|
|
if (window.location.port === "3007") {
|
|
|
|
|
// let timestamp=railsgettimes(proxy);
|
|
|
|
|
// console.log(timestamp)
|
|
|
|
|
// `https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`
|
|
|
|
|
railsgettimes( `${proxy}/api/main/first_stamp.json`);
|
|
|
|
|
let newopens=md5(opens+timestamp)
|
|
|
|
|
config.url = `${proxy}${url}`;
|
|
|
|
|
if (config.url.indexOf('?') == -1) {
|
|
|
|
|
config.url = `${config.url}?debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|
} else {
|
|
|
|
|
config.url = `${config.url}&debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 加api前缀
|
|
|
|
|
// railsgettimes(`http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`);
|
|
|
|
|
|
|
|
|
|
railsgettimes( `/api/main/first_stamp.json`);
|
|
|
|
|
let newopens=md5(opens+timestamp)
|
|
|
|
|
config.url = url;
|
|
|
|
|
if (config.url.indexOf('?') == -1) {
|
|
|
|
|
config.url = `${config.url}?randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|
} else {
|
|
|
|
|
config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setpostcookie();
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// console.log(config);
|
|
|
|
|
if (requestMap[config.url] === true) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// // 非file_update请求
|
|
|
|
|
if (config.url.indexOf('update_file') === -1) {
|
|
|
|
|
requestMap[config.url] = true;
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------- 測試3007连测试服的代码
|
|
|
|
|
// if (url.indexOf('file_update') != -1 || url.indexOf('game_build') != -1 || url.indexOf('game_status') != -1) {
|
|
|
|
|
// proxy = 'https://testbdweb.trustie.net'
|
|
|
|
|
// } else {
|
|
|
|
|
// 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];
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|