anxiao_web/pages/index/js/session.js

33 lines
748 B
JavaScript
Raw Permalink Normal View History

2024-07-24 09:22:32 +08:00
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}