From ec9d8982d61d688e759055698f054c8ece423740 Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Mon, 18 Nov 2024 09:25:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 1 + src/utils/request.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/App.vue b/src/App.vue index f7ef837..7f83a74 100644 --- a/src/App.vue +++ b/src/App.vue @@ -30,6 +30,7 @@ const resetTimer = () => { } 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..e5fc36c 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -40,6 +40,7 @@ axios.interceptors.response.use( let backurl=window.location.href; tools.data.set("backUrl",backurl); + tools.data.remove('token'); router.replace({ path: "/guide", }); From 35267927453f8caff1f044c031086878008708fa Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Mon, 18 Nov 2024 09:36:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/guide.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/view/guide.vue b/src/view/guide.vue index 655d9c0..2860500 100644 --- a/src/view/guide.vue +++ b/src/view/guide.vue @@ -217,7 +217,8 @@ const login = () => { } } else { var tokenPd = getCookie("lytoken"); - if (!tokenPd) { + var tokenLogin=tools.data.get("token"); + if (!tokenPd && !tokenLogin) { window.location.href = "https://jzzf.longyou.gov.cn:998/api/login?returnURL=" + window.location.href; From bf2d7cadad74537dff164bf93e6f97dea55be1f0 Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Mon, 18 Nov 2024 09:49:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8F=96=E6=B6=88cookie=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E5=BE=8B=E7=94=A8token=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 16 ++++++++-------- src/utils/request.js | 14 +++++++------- src/view/guide.vue | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/App.vue b/src/App.vue index 7f83a74..edec5d4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,14 +20,14 @@ 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'); diff --git a/src/utils/request.js b/src/utils/request.js index e5fc36c..bc76688 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,13 +30,13 @@ 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); diff --git a/src/view/guide.vue b/src/view/guide.vue index 2860500..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,9 +216,9 @@ const login = () => { tools.data.remove("backUrl"); } } else { - var tokenPd = getCookie("lytoken"); + // var tokenPd = getCookie("lytoken"); var tokenLogin=tools.data.get("token"); - if (!tokenPd && !tokenLogin) { + if (!tokenLogin) { window.location.href = "https://jzzf.longyou.gov.cn:998/api/login?returnURL=" + window.location.href;