dev_tpm_ui
杨树明 6 years ago
parent 61ccc059c7
commit 7c45fd9185

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

@ -31,13 +31,15 @@ class ShixunsHome extends Component {
} }
} }
componentDidMount(){ componentDidMount(){
configShareForIndex() configShareForIndex()
const upsystem=`/users/system_update.json`; const upsystem=`/users/system_update.json`;
axios.get(upsystem).then((response)=>{ axios.get(upsystem).then((response)=>{
let updata=response.data; if(response.data){
this.setState({ let updata=response.data;
updata:updata this.setState({
}) updata:updata
})
}
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
}) })
@ -50,7 +52,7 @@ class ShixunsHome extends Component {
}) })
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error) // console.log(error)
}); });
} }

@ -1100,9 +1100,6 @@ submittojoinclass=(value)=>{
{/*<a href={this.props.Headertop===undefined?"":this.props.Headertop.course_url}>课堂</a>*/} {/*<a href={this.props.Headertop===undefined?"":this.props.Headertop.course_url}>课堂</a>*/}
<Link to={this.props.Headertop===undefined?"":'/courses'}>翻转课堂</Link> <Link to={this.props.Headertop===undefined?"":'/courses'}>翻转课堂</Link>
</li> </li>
{}
{console.log(activeShixuns)}
<li className={`${activeShixuns === true ? 'pr active' : 'pr'}`}> <li className={`${activeShixuns === true ? 'pr active' : 'pr'}`}>
<Link to="/shixuns">实训项目</Link> <Link to="/shixuns">实训项目</Link>
{/*<img src={getImageUrl("images/educoder/hot-h.png")} className="nav-img">*/} {/*<img src={getImageUrl("images/educoder/hot-h.png")} className="nav-img">*/}

Loading…
Cancel
Save