From 8071a4a86c1f23f556488c0243db629d2a2c38ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AE=8F=E6=9D=B0?= <1943105267@qq.com> Date: Thu, 30 Nov 2023 14:59:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DtagsView=E9=80=80=E5=87=BA?= =?UTF-8?q?=E4=B8=8D=E6=B8=85=E9=99=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 3 +-- src/layout/components/Navbar.vue | 7 ++----- src/store/modules/tagsView.js | 7 ++++++- src/utils/request.js | 7 ++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.env.production b/.env.production index 9534587..c2c253d 100644 --- a/.env.production +++ b/.env.production @@ -8,5 +8,4 @@ ENV = 'production' VUE_APP_BASE_API = 'https://www.jichuanglanhai.com:9038' -#服务器环境退出登录问题 -VUE_APP_LOGIN_OUT="/demo/netEwm" + diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 7e92b5d..43f5ff3 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -111,11 +111,8 @@ export default { }) .then(() => { this.$store.dispatch("LogOut").then(() => { - if (process.env.NODE_ENV == "production") { - location.href = process.env.VUE_APP_LOGIN_OUT + "/login"; - } else { - location.href = "/login"; - } + this.$store.dispatch("tagsView/closeVisitedView", []); + this.$router.replace("/login"); }); }) .catch(() => {}); diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index 5c31261..e51114a 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -6,7 +6,9 @@ const state = { const mutations = { CLOSE_LIST: (state, list) => { - state.visitedViews = list; + state.visitedViews = []; + state.cachedViews = []; + state.iframeViews = []; }, ADD_IFRAME_VIEW: (state, view) => { if (state.iframeViews.some((v) => v.path === view.path)) return; @@ -128,6 +130,9 @@ const mutations = { }; const actions = { + closeVisitedView({ commit }, view) { + commit("CLOSE_LIST", view); + }, addView({ dispatch }, view) { dispatch("addVisitedView", view); dispatch("addCachedView", view); diff --git a/src/utils/request.js b/src/utils/request.js index 927f081..4ed4d7f 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -120,11 +120,8 @@ service.interceptors.response.use( .then(() => { isRelogin.show = false; store.dispatch("LogOut").then(() => { - if (process.env.NODE_ENV == "production") { - location.href = process.env.VUE_APP_LOGIN_OUT + "/login"; - } else { - location.href = "/login"; - } + store.dispatch("tagsView/closeVisitedView", []); + router.replace("/login"); }); }) .catch(() => {