From fc2c60776d83cdd8e187519ea592712aae18d889 Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Wed, 13 Nov 2024 10:05:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=97=B4=E6=9C=AA?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/utils/request.js | 3 ++- src/view/guide.vue | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/App.vue b/src/App.vue index a33e020..2586915 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/src/utils/request.js b/src/utils/request.js index ab56c12..e19667d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,7 @@ import axios from "axios"; import { ElMessage } from "element-plus"; import tools from "@/utils/tools"; import router from "../router"; -// axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/' +axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/' axios.defaults.timeout = 120000; // HTTP request 拦截器 @@ -37,6 +37,7 @@ axios.interceptors.response.use( const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"; } + let backurl=window.location.href; tools.data.set("backUrl",backurl); router.replace({ diff --git a/src/view/guide.vue b/src/view/guide.vue index 825ba16..08093e5 100644 --- a/src/view/guide.vue +++ b/src/view/guide.vue @@ -137,6 +137,8 @@ const getCookie = (cname) => { }; // 登录 const login = () => { + console.log(111111111); + let backurl = tools.data.get("backUrl"); dd.getAuthCode() .then((res) => { @@ -153,6 +155,8 @@ const login = () => { tools.data.set("type", 1); getMenu(); if (backurl) { + console.log(222222); + window.location.href = backurl; tools.data.remove("backUrl"); } @@ -210,13 +214,17 @@ const login = () => { tools.data.set("token", token); tools.data.set("type", 2); getMenu(); + window.addEventListener("mousemove", resetTimer); + window.addEventListener("keydown", resetTimer); if (backurl) { + console.log(33333333333); window.location.href = backurl; tools.data.remove("backUrl"); } } else { var tokenPd = getCookie("lytoken"); if (!tokenPd) { + ElMessage.error("11111111!"); window.location.href = "http://220.191.238.50:996/api/login?returnURL=" + window.location.href; @@ -226,6 +234,7 @@ const login = () => { } }); }; + //头部菜单 const getMenu = () => { http.get(`/api/ggfwyth/account/roleMenu`).then((res) => { @@ -244,6 +253,34 @@ const reset_font = () => { document.querySelector("#m").style.transform = "scale(" + width / 1920 + "," + height / 1080 + ")"; }; +//未操作,退出登录 +const inactivityTimer = ref(null); +const resetTimer = () => { + clearTimeout(inactivityTimer.value); + inactivityTimer.value = setTimeout(() => { + // 执行注销操作或者跳转到登录页面的代码 + // ElMessage.error("请重新登录!"); + // 清空cook + ElMessage.error("长时间未操作,请重新登录"); + window.removeEventListener("mousemove", resetTimer); + window.removeEventListener("keydown", resetTimer); + const cookies = document.cookie.split(";"); + for (let i = 0; i < cookies.length; i++) { + const cookie = cookies[i]; + const eqPos = cookie.indexOf("="); + const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; + document.cookie = + name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"; + } + let backurl = window.location.href; + tools.data.set("backUrl", backurl); + router.replace({ + path: "/guide", + }); + window.location.href = + "http://220.191.238.50:996/api/login?returnURL=" + window.location.href; + }, 30 * 60 * 1000); // 30分钟 +}; onMounted(() => { login(); From faaf54ea60618fe9c5e9f07a65d9e2c0956bd95b Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Wed, 13 Nov 2024 10:05:41 +0800 Subject: [PATCH 2/2] 1 --- src/view/guide.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/view/guide.vue b/src/view/guide.vue index 08093e5..39ec9bf 100644 --- a/src/view/guide.vue +++ b/src/view/guide.vue @@ -224,7 +224,6 @@ const login = () => { } else { var tokenPd = getCookie("lytoken"); if (!tokenPd) { - ElMessage.error("11111111!"); window.location.href = "http://220.191.238.50:996/api/login?returnURL=" + window.location.href;