Compare commits
3 Commits
e0bc528d5d
...
57020922ee
Author | SHA1 | Date |
---|---|---|
姚宇浩 | 57020922ee | |
姚宇浩 | 5ef97f2125 | |
姚宇浩 | 5a2b6e23d4 |
43
src/App.vue
43
src/App.vue
|
@ -1,3 +1,44 @@
|
||||||
<template>
|
<template>
|
||||||
<router-view />
|
<router-view />
|
||||||
</template>
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, onUnmounted, reactive } from "vue";
|
||||||
|
import { useRouter, useRoute } from "vue-router";
|
||||||
|
import tools from "@/utils/tools";
|
||||||
|
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>
|
||||||
|
|
|
@ -210,8 +210,8 @@ const login = () => {
|
||||||
tools.data.set("token", token);
|
tools.data.set("token", token);
|
||||||
tools.data.set("type", 2);
|
tools.data.set("type", 2);
|
||||||
getMenu();
|
getMenu();
|
||||||
window.addEventListener("mousemove", resetTimer);
|
// window.addEventListener("mousemove", resetTimer);
|
||||||
window.addEventListener("keydown", resetTimer);
|
// window.addEventListener("keydown", resetTimer);
|
||||||
if (backurl) {
|
if (backurl) {
|
||||||
window.location.href = backurl;
|
window.location.href = backurl;
|
||||||
tools.data.remove("backUrl");
|
tools.data.remove("backUrl");
|
||||||
|
@ -248,33 +248,33 @@ const reset_font = () => {
|
||||||
"scale(" + width / 1920 + "," + height / 1080 + ")";
|
"scale(" + width / 1920 + "," + height / 1080 + ")";
|
||||||
};
|
};
|
||||||
//未操作,退出登录
|
//未操作,退出登录
|
||||||
const inactivityTimer = ref(null);
|
// const inactivityTimer = ref(null);
|
||||||
const resetTimer = () => {
|
// const resetTimer = () => {
|
||||||
clearTimeout(inactivityTimer.value);
|
// clearTimeout(inactivityTimer.value);
|
||||||
inactivityTimer.value = setTimeout(() => {
|
// inactivityTimer.value = setTimeout(() => {
|
||||||
// 执行注销操作或者跳转到登录页面的代码
|
// // 执行注销操作或者跳转到登录页面的代码
|
||||||
// ElMessage.error("请重新登录!");
|
// // ElMessage.error("请重新登录!");
|
||||||
// 清空cook
|
// // 清空cook
|
||||||
ElMessage.error("长时间未操作,请重新登录");
|
// ElMessage.error("长时间未操作,请重新登录");
|
||||||
window.removeEventListener("mousemove", resetTimer);
|
// window.removeEventListener("mousemove", resetTimer);
|
||||||
window.removeEventListener("keydown", resetTimer);
|
// window.removeEventListener("keydown", resetTimer);
|
||||||
const cookies = document.cookie.split(";");
|
// const cookies = document.cookie.split(";");
|
||||||
for (let i = 0; i < cookies.length; i++) {
|
// for (let i = 0; i < cookies.length; i++) {
|
||||||
const cookie = cookies[i];
|
// const cookie = cookies[i];
|
||||||
const eqPos = cookie.indexOf("=");
|
// const eqPos = cookie.indexOf("=");
|
||||||
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
// const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
||||||
document.cookie =
|
// document.cookie =
|
||||||
name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;";
|
// name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;";
|
||||||
}
|
// }
|
||||||
let backurl = window.location.href;
|
// let backurl = window.location.href;
|
||||||
tools.data.set("backUrl", backurl);
|
// tools.data.set("backUrl", backurl);
|
||||||
router.replace({
|
// router.replace({
|
||||||
path: "/guide",
|
// path: "/guide",
|
||||||
});
|
// });
|
||||||
window.location.href =
|
// window.location.href =
|
||||||
"http://220.191.238.50:996/api/login?returnURL=" + window.location.href;
|
// "http://220.191.238.50:996/api/login?returnURL=" + window.location.href;
|
||||||
}, 30 * 60 * 1000); // 30分钟
|
// }, 30 * 60 * 1000); // 30分钟
|
||||||
};
|
// };
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
login();
|
login();
|
||||||
|
|
Loading…
Reference in New Issue