|
|
|
@ -8,6 +8,8 @@ import { notification } from 'antd';
|
|
|
|
|
import './index.css';
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
const opens ="79e33abd4b6588941ab7622aed1e67e8";
|
|
|
|
|
let timestamp;
|
|
|
|
|
let checkSubmitFlg = false;
|
|
|
|
|
broadcastChannelOnmessage('refreshPage', () => {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
})
|
|
|
|
@ -19,7 +21,7 @@ function locationurl(list){
|
|
|
|
|
window.location.href=list
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let hashTimeout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 开发期多个身份切换
|
|
|
|
|
let debugType =""
|
|
|
|
@ -39,7 +41,29 @@ if (isDev) {
|
|
|
|
|
//ebugType="teacher";
|
|
|
|
|
// 学生
|
|
|
|
|
//debugType="student";
|
|
|
|
|
|
|
|
|
|
window.railsgettimes = function(proxy) {
|
|
|
|
|
if(timestamp&&checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 3500);
|
|
|
|
|
}else if(checkSubmitFlg===false){
|
|
|
|
|
$.ajax({url:proxy,async:false,success:function(data){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
timestamp=data.message;
|
|
|
|
|
}
|
|
|
|
|
}})
|
|
|
|
|
checkSubmitFlg=true
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
checkSubmitFlg=false;
|
|
|
|
|
}, 3500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
window._debugType = debugType;
|
|
|
|
|
export function initAxiosInterceptors(props) {
|
|
|
|
|
initOnlineOfflineListener()
|
|
|
|
@ -62,17 +86,10 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
// 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制
|
|
|
|
|
const requestMap = {};
|
|
|
|
|
|
|
|
|
|
window.railsgettimes = function(proxy) {
|
|
|
|
|
$.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
|
|
|
|
|
if(data.status===0){
|
|
|
|
|
return data.message;
|
|
|
|
|
}
|
|
|
|
|
}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.setfalseInRequestMap = function(keyName) {
|
|
|
|
|
requestMap[keyName] = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.interceptors.request.use(
|
|
|
|
|
config => {
|
|
|
|
|
|
|
|
|
@ -102,8 +119,7 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
}
|
|
|
|
|
if(`${config[0]}`!=`true`){
|
|
|
|
|
if (window.location.port === "3007") {
|
|
|
|
|
let timestamp=railsgettimes(proxy);
|
|
|
|
|
console.log(timestamp)
|
|
|
|
|
railsgettimes(`${proxy}/api/main/first_stamp.json`);
|
|
|
|
|
let newopens=md5(opens+timestamp)
|
|
|
|
|
config.url = `${proxy}${url}`;
|
|
|
|
|
if (config.url.indexOf('?') == -1) {
|
|
|
|
@ -113,6 +129,7 @@ export function initAxiosInterceptors(props) {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 加api前缀
|
|
|
|
|
railsgettimes(`/api/main/first_stamp.json`);
|
|
|
|
|
config.url = url;
|
|
|
|
|
if (config.url.indexOf('?') == -1) {
|
|
|
|
|
config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`;
|
|
|
|
|