33 lines
748 B
JavaScript
33 lines
748 B
JavaScript
|
|
||
|
import { stationurl } from "../../../public/js/url.js";
|
||
|
import { layuiObj } from "./index.js";
|
||
|
var heartbeat=5;
|
||
|
var tokenTime=60000;
|
||
|
//设置token的保活
|
||
|
function setTokenActive(){
|
||
|
setInterval(()=>{
|
||
|
var url=stationurl + "/firectrl/client/user/active";
|
||
|
heartbeat--;
|
||
|
if(heartbeat==0){
|
||
|
//登出以后,销毁session
|
||
|
layuiObj["layer"].confirm("网络连接中断...请重新的登录", {
|
||
|
btn:[ '确定'],
|
||
|
title:false,
|
||
|
closeBtn:false,
|
||
|
shade: 0.5,
|
||
|
}, function(index) {
|
||
|
console.log("退出")
|
||
|
});
|
||
|
}
|
||
|
axios({
|
||
|
method:'post',
|
||
|
url:url,
|
||
|
}).then(res => {
|
||
|
heartbeat=5;
|
||
|
}).catch(function(error) {
|
||
|
console.log(error)
|
||
|
})
|
||
|
},tokenTime)
|
||
|
}
|
||
|
export {setTokenActive}
|