From 41179a302248f06bea9dd00a3a35eb36001dc0d5 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 19 May 2021 15:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=80=E5=87=BA=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TestPanel.vue | 2 +- src/config/index.js | 6 +++++- src/views/Home.vue | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 6e4cc72..b67ec3d 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -163,7 +163,7 @@ export default { return { systemId: this.$config.systemId, test: [], - ishow: false, + ishow: true, grade: "00", exampleData: "", codeid: "", diff --git a/src/config/index.js b/src/config/index.js index eef9392..7c9ab78 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -12,5 +12,9 @@ export default { /** * @description 跳转子系统链接 */ - systemId: 4 + systemId: 4, + /** + * @description 长时间未操作,自动退出登录时间 + */ + autoLogoutTime: 3600000 } \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index 0f81d29..4b73a23 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -130,6 +130,7 @@ export default { this.leavePage() }, mounted() { + this.autoLogout() this.assessmentId = this.getCookie("assessmentId"); if (window.history && window.history.pushState) { // 向历史记录中插入了当前页 @@ -155,6 +156,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() { this.leavePage() history.back()