This commit is contained in:
duanxiaohai 2024-10-08 11:04:14 +08:00
parent d7495e8fa5
commit 538e32fc7e
2 changed files with 48 additions and 33 deletions

View File

@ -30,6 +30,7 @@ axios.interceptors.response.use(
if (error.response) { if (error.response) {
if (error.response.status == 401) { if (error.response.status == 401) {
ElMessage.error("请重新登录!"); ElMessage.error("请重新登录!");
// 清空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];
@ -37,6 +38,7 @@ axios.interceptors.response.use(
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=/;";
} }
router.replace({ router.replace({
path: "/guide", path: "/guide",
}); });

View File

@ -160,9 +160,12 @@ const login = () => {
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
// var token = getCookie("lytoken");
var token = "6b0e380b4a8f46baae4923f83faf670d"; var tokenU = routers.query.token;
// console.log('token', token) // tokenU = "6b0e380b4a8f46baae4923f83faf670d";
if (tokenU) {
document.cookie = `lytoken=${tokenU}`;
var token = getCookie("lytoken");
if (!token) { if (!token) {
window.location.href = window.location.href =
"http://220.191.238.50:996/api/login?returnURL=" + "http://220.191.238.50:996/api/login?returnURL=" +
@ -171,6 +174,16 @@ const login = () => {
tools.data.set("token", token); tools.data.set("token", token);
tools.data.set("type", 2); tools.data.set("type", 2);
} }
} else {
window.location.href =
"http://220.191.238.50:996/api/login?returnURL=" +
window.location.href;
}
// var token = getCookie("lytoken");
console.log(routers.query.token);
// console.log('token', token)
}); });
}; };