diff --git a/src/App.vue b/src/App.vue index f7ef837..edec5d4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,16 +20,17 @@ const resetTimer = () => { 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=/;"; - } + // 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); + tools.data.remove('token'); router.replace({ path: "/guide", }); diff --git a/src/utils/request.js b/src/utils/request.js index e19667d..bc76688 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,16 +30,17 @@ axios.interceptors.response.use( if (error.response.status == 401) { ElMessage.error("请重新登录!"); // 清空cook - 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=/;"; - } + // 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); + tools.data.remove('token'); router.replace({ path: "/guide", }); diff --git a/src/view/guide.vue b/src/view/guide.vue index 655d9c0..d47e82f 100644 --- a/src/view/guide.vue +++ b/src/view/guide.vue @@ -201,11 +201,11 @@ const login = () => { const decodedText = decrypt(encryptedText, ENCODED_KEY); // console.log("Decrypted Text:", decodedText); var tokenU = decodedText; - if (getCookie("lytoken")) { - } else { - document.cookie = `lytoken=${tokenU}`; - } - var token = getCookie("lytoken"); + // if (getCookie("lytoken")) { + // } else { + // document.cookie = `lytoken=${tokenU}`; + // } + var token = tokenU; tools.data.set("token", token); tools.data.set("type", 2); getMenu(); @@ -216,8 +216,9 @@ const login = () => { tools.data.remove("backUrl"); } } else { - var tokenPd = getCookie("lytoken"); - if (!tokenPd) { + // var tokenPd = getCookie("lytoken"); + var tokenLogin=tools.data.get("token"); + if (!tokenLogin) { window.location.href = "https://jzzf.longyou.gov.cn:998/api/login?returnURL=" + window.location.href;