自动退出等

master
yujialong 4 years ago
parent 4f7c467574
commit 6487eeaf7d
  1. 2
      src/components/TestPanel.vue
  2. 6
      src/config/index.js
  3. 15
      src/views/Home.vue

@ -163,7 +163,7 @@ export default {
return { return {
systemId: this.$config.systemId, systemId: this.$config.systemId,
test: [], test: [],
ishow: false, ishow: true,
grade: "00", grade: "00",
exampleData: "", exampleData: "",
codeid: "", codeid: "",

@ -12,5 +12,9 @@ export default {
/** /**
* @description 跳转子系统链接 * @description 跳转子系统链接
*/ */
systemId: 8 systemId: 8,
/**
* @description 长时间未操作自动退出登录时间
*/
autoLogoutTime: 3600000
} }

@ -129,6 +129,7 @@ export default {
this.leavePage() this.leavePage()
}, },
mounted() { mounted() {
this.autoLogout()
this.assessmentId = this.getCookie("assessmentId"); this.assessmentId = this.getCookie("assessmentId");
if (window.history && window.history.pushState) { if (window.history && window.history.pushState) {
// //
@ -154,6 +155,20 @@ export default {
} }
} }
}, },
autoLogout(){
let lastTime = new Date().getTime()
let logout = false
document.onmousedown = () => {
lastTime = new Date().getTime()
}
setInterval(() => {
if((new Date().getTime() - lastTime) > this.$config.autoLogoutTime){
logout || this.$message.error('用户登录过期,请重新登录')
logout = true
setTimeout(this.back,1500)
}
},1000)
},
goBack() { goBack() {
this.leavePage() this.leavePage()
history.back() history.back()

Loading…
Cancel
Save