This commit is contained in:
duanxiaohai 2024-11-15 16:29:51 +08:00
commit acda64cbfa
2 changed files with 72 additions and 31 deletions

View File

@ -1,3 +1,45 @@
<template>
<router-view />
</template>
<script setup>
import { ref, onMounted, onUnmounted, reactive } from "vue";
import { useRouter, useRoute } from "vue-router";
import tools from "@/utils/tools";
import { ElMessage } from "element-plus";
const router = useRouter();
const inactivityTimer = ref(null);
const resetTimer = () => {
// console.log("");
let typeE = tools.data.get("type");
if (typeE == "2") {
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(() => {
window.addEventListener("mousemove", resetTimer);
window.addEventListener("keydown", resetTimer);
});
</script>

View File

@ -79,7 +79,6 @@ import png5 from "@/assets/guide/Dp/5.png";
import png6 from "@/assets/guide/Dp/6.png";
import png7 from "@/assets/guide/Dp/7.png";
import png8 from "@/assets/guide/Dp/8.png";
import { ElMessage } from "element-plus";
import tools from "@/utils/tools";
import CryptoJS from "crypto-js";
const router = useRouter();
@ -210,8 +209,8 @@ const login = () => {
tools.data.set("token", token);
tools.data.set("type", 2);
getMenu();
window.addEventListener("mousemove", resetTimer);
window.addEventListener("keydown", resetTimer);
// window.addEventListener("mousemove", resetTimer);
// window.addEventListener("keydown", resetTimer);
if (backurl) {
window.location.href = backurl;
tools.data.remove("backUrl");
@ -248,33 +247,33 @@ const reset_font = () => {
"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 =
"https://jzzf.longyou.gov.cn:998/api/login?returnURL=" + window.location.href;
}, 30 * 60 * 1000); // 30
};
// 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();