取消cookie,一律用token判断
This commit is contained in:
parent
3526792745
commit
bf2d7cadad
16
src/App.vue
16
src/App.vue
|
@ -20,14 +20,14 @@ const resetTimer = () => {
|
||||||
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);
|
||||||
tools.data.remove('token');
|
tools.data.remove('token');
|
||||||
|
|
|
@ -30,13 +30,13 @@ axios.interceptors.response.use(
|
||||||
if (error.response.status == 401) {
|
if (error.response.status == 401) {
|
||||||
ElMessage.error("请重新登录!");
|
ElMessage.error("请重新登录!");
|
||||||
// 清空cook
|
// 清空cook
|
||||||
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 = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;";
|
// document.cookie = 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);
|
||||||
|
|
|
@ -201,11 +201,11 @@ const login = () => {
|
||||||
const decodedText = decrypt(encryptedText, ENCODED_KEY);
|
const decodedText = decrypt(encryptedText, ENCODED_KEY);
|
||||||
// console.log("Decrypted Text:", decodedText);
|
// console.log("Decrypted Text:", decodedText);
|
||||||
var tokenU = decodedText;
|
var tokenU = decodedText;
|
||||||
if (getCookie("lytoken")) {
|
// if (getCookie("lytoken")) {
|
||||||
} else {
|
// } else {
|
||||||
document.cookie = `lytoken=${tokenU}`;
|
// document.cookie = `lytoken=${tokenU}`;
|
||||||
}
|
// }
|
||||||
var token = getCookie("lytoken");
|
var token = tokenU;
|
||||||
tools.data.set("token", token);
|
tools.data.set("token", token);
|
||||||
tools.data.set("type", 2);
|
tools.data.set("type", 2);
|
||||||
getMenu();
|
getMenu();
|
||||||
|
@ -216,9 +216,9 @@ const login = () => {
|
||||||
tools.data.remove("backUrl");
|
tools.data.remove("backUrl");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var tokenPd = getCookie("lytoken");
|
// var tokenPd = getCookie("lytoken");
|
||||||
var tokenLogin=tools.data.get("token");
|
var tokenLogin=tools.data.get("token");
|
||||||
if (!tokenPd && !tokenLogin) {
|
if (!tokenLogin) {
|
||||||
window.location.href =
|
window.location.href =
|
||||||
"https://jzzf.longyou.gov.cn:998/api/login?returnURL=" +
|
"https://jzzf.longyou.gov.cn:998/api/login?returnURL=" +
|
||||||
window.location.href;
|
window.location.href;
|
||||||
|
|
Loading…
Reference in New Issue